Add CI to the Affected CIs tab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 07:13 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 07:32 PM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 03:32 PM
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:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 04:13 PM
Thanks for the update.