The CreatorCon Call for Content is officially open! Get started here.

Run script not working in Workflow - but working in BACKGROUND SCRIPT

Jagadish Sanadi
Kilo Sage

Run script not working in Workflow - but working in BACKGROUND SCRIPT

 

var sys_id_maintain = current.variables.product_catalog_item;
var grAppIns = new GlideRecord('sc_cat_item');
grAppIns.addQuery('sys_id', sys_id_maintain);
grAppIns.query();

//update the catalog item with source values
while (grAppIns.next()) {
grAppIns.setValue('name', current.variables.description);

grAppIns.update();

}

 

Type of current.variables.description is 'HTML' and in sc_cat_item the type of variable for description is 'Translated HTML'

1 ACCEPTED SOLUTION

Jagadish Sanadi
Kilo Sage

Thank You for all your help.

 

Created scratchpad variables to save current.variable values and tried update. It worked

View solution in original post

6 REPLIES 6

Hemanth M1
Giga Sage
Giga Sage

Hi @Jagadish Sanadi ,

 

Can you try

grAppIns.name = current.variables.description.toString(); instead grAppIns.setValue('name', current.variables.description);

 

1)i would also make sure i am getting expected sys_id of the catalog item in "sys_id_maintain"

2)Check if info/errors logs in the workflow

3)i would also check the system has access to update the name field on the catalog item by validate "grAppIns.canWrite()" in while condition

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Jagadish Sanadi
Kilo Sage

Thank You for all your help.

 

Created scratchpad variables to save current.variable values and tried update. It worked