Add CI to the Affected CIs tab

carlocsa
Kilo Expert

Hi ServiceNow Gurus,

I am working on a catalogue item. One of the fields, which we will call u_FIELD_A has 2 options "OPTION_A" and "OPTION_B". If Option A is selected, a CI (example: ServiceNow) will need to be related or added to the Affected CIs tab after submitting the request, If Option B, a different CI (example: Samsung) will be added. Can a catalogue client script be used to achieve this?

Thank you very much.

Carlo

3 REPLIES 3

Shishir Srivast
Mega Sage

I think we can have a After insert BR on sc_task table, when task is created then create a record in task_ci table for the same task, I believe something like below should help,



(function executeRule(current, previous /*null when async*/) {


var gr = new GlideRecord('task_ci');


gr.initialize();


if(current.request_item.variables.u_FIELD_A == 'OPTION_A')


gr.ci_item = 'SYS ID OF ServiceNow';


else if(current.request_item.variables.u_FIELD_A == 'OPTION_B')


gr.ci_item = 'SYS ID OF Samsung';


gr.task = current.sys_id;


gr.insert();


})(current, previous);


Hi Shishir,



The requirement for this has changed. I have created a field called 'configuration_item'. The behaviour should be:



(a) Populate 'configuration_item' with "ServiceNow" from cmdb_ci_appl if u_FIELD_A == 'OPTION_A'


(b) Populate 'configuration_item' with "Samsung" from cmdb_ci_appl if u_FIELD_A == 'OPTION_B'



My script is:



Capture.JPG


Thanks for the update.