Interview Question: How to call Client Script from Catalog Item or Catalog Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 01:29 AM
Hi Members,
In an interview it was asked to me to "How to call Client Script from Catalog Item or Catalog Client Script"?
Please suggest.
Thanks,
Neha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2025 02:04 AM
For requested item. On the client script form select the table as 'sc_req_item'. In the script, put the condition g_form.getValue('cat_item') == "<sys_id of your catalog item>". If the condition evaluates to true, then execute the remaining logic.
For request form, you have to take the sys_id of the current request form, do the glide record to fetch the child requested item and then apply the same condition with the glide record results.
For e.g. (This example is only for when there is only one requested item attached to a request)
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', g_form.getUniqueValue()); //getUniqueValue() gives the sys_id of the current record
gr.query();
if(gr.next()){
var item_name = gr.getDisplayValue('cat_item');
if(item_name == "<name of your catalog item>"){
//your remaining code logic
}
}