Auto Sync for form category field value to RITM Field Value

sneha Jvalageri
Tera Contributor
Hello Team,
As we used the script below to sync the form Category field values to RITM Category Field values, But it's not taking but in the log we are getting the catalog form category value but it is not Mapping to the RITM Category Value. Both field Types are Choice fields in the Form Level and also RITM Level 

We have written the below script in the workflow Run Script Activity. But it's not working 

var
category = current.variables.accenture_category;
gs.log('Test'+category);
var RITM = new GlideRecord ("sc_req_item");
RITM.addQuery("sys_id", current.sys_id);
RITM.query();
if (RITM.next())
{
gs.log('Test1' +category.getDisplayValue());
RITM.u_category = category.getDisplayValue();
//g_form.setValue('u_category',category);
RITM.update();
}
1 ACCEPTED SOLUTION

Voona Rohila
Kilo Patron
Kilo Patron

Hi @sneha Jvalageri 

You can simply use below code in the run-script activity

 

current.u_category = current.variables.accenture_category;

 

 

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/administer/workflow-activit...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

3 REPLIES 3

Voona Rohila
Kilo Patron
Kilo Patron

Hi @sneha Jvalageri 

You can simply use below code in the run-script activity

 

current.u_category = current.variables.accenture_category;

 

 

https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/administer/workflow-activit...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Thank you @Voona Rohila it worked i have another issue where we need to assign the Assignment group  based on the u_category field where this u_category field is a RITM level field not a variable field
example: If the category field has 4 to 5 options 1)Tree 2)Branch 3)stem 
once the user selects any one of the category as Tree it should assign to Tree Assignment group.
Please suggest me the script where i have used Run Script in the workflow

Hi 
you can write a simple if else if checks to assign based on category

if(current.variables.accenture_category == 'a')
{
//do something
}
else if(current.variables.accenture_category == 'b')
{
//do something

}
else if(current.variables.accenture_category == 'c')
{
//do something

}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP