Client Script | on SC_req_item

Ankita NA
Tera Contributor

Hi All,

I am in need of help for below onLoad client script which is written for sc_req_item table , the scope is RITM is getting created for catalog item in request table so based on the variables value of req type and application name in this RITM I need to set value of the cmdb_ci file on RITM.


My Req:

I req type is one of new, old or existing, then get value of application name and set the value of cmdb_ci field.


With below script its working only when the req type is new and for other two its setting blank value.


function onLoad() {

var item = g_form.getValue('cat_item');

var req_type = g_form.getValue('what_type_of_request'); // a select box field with with 4 choices(new, old, existing, modified)
var application_name = g_form.getValue('variables.u_application_name');// a reference field (referencing application table)which comes only when the request type is selected

if (item == '347ea76d97b51dd0bdc08f171153af8e' && (req_type == "new" ||req_type == "existing" || req_type == "old") {

g_form.setValue("cmdb_ci", application_name);

}
}


Thanks,
Ankita

5 REPLIES 5

@Ankita NA 

are you sure you are comparing the correct value for existing or old?

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