Modify Catalog Item RITM short description based on requested_for user location.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 12:02 AM
Hi Guys, We have a requirement for one specific Catalog Item to modify the RITM short description and add [India] to short description if requested for user (u_requested_for) location is "India" in sys_user table record. I would like to do this via catalog client script only as we have a common workflow for most of Catalog Items so don't want to touch the workflow but somehow not able to achieve the same via onsubmit catalog client script.
function onSubmit()
{
var user = new GlideRecord('sys_user');
user.addQuery('u_user_location',India);
user.addQuery('sys_id',g_form.getValue('u_requested_for'));
user.query();
while(user.next())
{
g_form.setValue('short_description','Catalog Item ABC [India]');
}
}
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 02:00 AM
Hi Ankur, Thanks for your prompt reply. I would like to achieve the same via Catalog client Script. I have already tried using BR and it was working fine with the help of OOB Conditions and actions in Business Rule. But, would like to achieve the same via Client side script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2020 02:27 AM
Hi Sarthak,
Using GlideRecord is not recommended in client script; so you can use below using g_form.getReference() with callback method
function onSubmit(){
var user = g_form.getReference('u_requested_for', callBackMethod);
}
function callBackMethod(user){
if(user.u_user_location == 'India')
g_form.setValue('short_description','Catalog Item ABC [India]');
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader