How to update a value in a table from workflow

surbhi_123
Tera Expert

I have a table called "Cloud Container" which has a field "Install Status" which is a choice option field having choices "Onboard" and "Not Onboard" . I have a catalog item with a refernce field "Cloud" referencing to Cloud Container field,

If the user selects a particular record from the "Cloud" field in catalog item then for that record selected the value of the "Install Status" field should be updated to "Onboard".

I am using run script activity in WF but the value is not getting updated.

var gr=new GlideRecord('u_cloud_container');
gr.addQuery('name',current.variables.cloud_resource_container);
gr.query();
while(gr.next()){
gr.install_status = "Onboard";
gr.update();
}

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @surbhi_123 

 

Try with below script - i made a change to query by sys_id instead of name

var gr=new GlideRecord('u_cloud_container');
gr.addQuery('sys_id',current.variables.cloud_resource_container.sys_id);
gr.query();
while(gr.next()){
gr.install_status = "Onboard";
gr.update();
}

 

View solution in original post

2 REPLIES 2

Manmohan K
Tera Sage

Hi @surbhi_123 

 

Try with below script - i made a change to query by sys_id instead of name

var gr=new GlideRecord('u_cloud_container');
gr.addQuery('sys_id',current.variables.cloud_resource_container.sys_id);
gr.query();
while(gr.next()){
gr.install_status = "Onboard";
gr.update();
}

 

jaheerhattiwale
Mega Sage
Mega Sage

@surbhi_123 Update the script like below

 

var gr=new GlideRecord('u_cloud_container');
gr.addQuery('sys_id',current.variables.cloud_resource_container);
gr.query();
while(gr.next()){
gr.install_status = "Onboard";
gr.update();
}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023