I want to update affected_ci in the realted list of RITM table to get updated as per catalog variables && configuration item field on RITM form.

Kingstan M
Kilo Sage

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.

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Vasantharajan N
Giga Sage
Giga Sage

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

View solution in original post

5 REPLIES 5

Vasantharajan N
Giga Sage
Giga Sage

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

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);

find_real_file.png

Please make sure the selected CI is meet the criteria of your reference qualifier "u_exclude_from_reference!=true"


Thanks & Regards,
Vasanth

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader