- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 04:05 AM
Hello SNC,
I am trying to update affected_ci in the related list of RITM table to get updated as per catalog variables >> server.
configuration item field on RITM form takes the value from variable by simple onLoad script but setting up affected_ci is being a challenge.
Any advice?
function onLoad() {
//Type appropriate comment here, and begin script below
// >> topic >> set configuration_item field name value same as server variable
var ciVariable = g_form.getValue('server');
g_form.setValue('configuration_item', ciVariable);
}
How i can achieve this via client onLoad script? or by any method.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 04:12 AM
You can use Before insert Business Rule on sc_req_item table and add the line in advanced script section
current.cmdb_ci - current.variables.catalog_variable_name_hold_ci;
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 04:12 AM
You can use Before insert Business Rule on sc_req_item table and add the line in advanced script section
current.cmdb_ci - current.variables.catalog_variable_name_hold_ci;
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 04:21 AM
affected_ci seems to get updated.
BUT - configuration item field is still empty
// >> topic >> BR to set configuration item field and affected_ci related list with server value
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
current.cmdb_ci = current.variables.server;
current.configuration_item = current.variables.server;
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 05:31 AM
Please make sure the selected CI is meet the criteria of your reference qualifier "u_exclude_from_reference!=true"
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 05:35 AM
Hi,
you can use workflow run script present on your catalog item to create records into Affected CI Related list
Script will be like this
current.cmdb_ci = current.variables.variableName;
var server = current.variables.server.toString().split(',');
for(var i=0;i<server.length;i++){
var rec = new GlideRecord("task_ci");
rec.initialize();
rec.ci_item = server[i];
rec.task = current.sys_id;
rec.insert();
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader