How to auto populate configuration item field in incident form?

Nitin21
Tera Contributor

How to auto populate configuration item field in incident form when 'xyz' option is selected from category choice field (reference). The configuration item field should display one (asset assigned first to user) of the many asset numbers assigned to user. 

7 REPLIES 7

Hi @Nitin21 , 

First you need to share the mapping approach of category/subcategory with CI.

As you know, category/sub-category on incident from configured in Choice [ sys_choice ] table , once it's selected , we have back-end value, now use this value to find the CI from the mapping source. 

 

So logic/code is entirely depend on mapping source, if using cmdb_ci's category/sub-category column for this mapping then, you can use the approach shared by @Sumanth16.

 

 

-Thanks,

AshishKM 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Sumanth16
Kilo Patron

Hi @Nitin21 ,

 

The CI field on incident table comes from Task table. So you need to do dictionary Override and CI field is dependent on Company field in task table. you need to change this dependent to Service Offering field. Refer below screenshot to do the change.

Sumanth16_0-1710771333895.png

 

Your reference qualifier will be like below

javascript:new getDate().getCis(current.service_offering); // new ScriptIncludeName().functionName(current.service_offering);

 

then create a script include

Script:

    getCis: function(so) {    
        var getCiArr = [];
        if (so) {
            var gr = new GlideRecord('cmdb_rel_ci');
            gr.addQuery('parent', so);
            gr.query();
            while (gr.next()) {
                getCiArr.push(gr.child.sys_id);
            }
                return "sys_idIN" + getCiArr.join(',');
        }

    },
 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Thank you, I'm struggling to understand this but could you please reupload that pic with better resolution. Even after zooming, can't deduce anything. 

Nitin21_0-1710771793721.png