OnSubmit Catalog client script to update custom field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-07-2021 04:34 AM
Hello,
I have a requirement to get the variable value & check in my custom table for matching record & then to update the state value to 'completed' in my custom table.
I am using a OnSubmit catalog client script but it is not updating my custom table field state.
Type:OnSubmit
Catalog Item: Source Form Details
Script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var sId = g_form.getValue('source_id'); // variable value
var gr = new GlideRecord('u_customtable'); // custom table
gr.addQuery('u_source','=',sId); // checking source id is available in my custom table
gr.query();
if(gr.next()){
var sts = gr.u_state;
g_form.setValue(sts,'Completed'); // setting the value of my custom table to 'Completed' but not working.
gr.update();
}
else{
// do nothing
}
}
Is this a correct approch or iam missing something. Plz help.
Thx,
JR
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â05-07-2021 07:46 AM
Thank you for marking my response as helpful.
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader