- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 12:02 AM
if there are multiple catalog items with same wf but every time description field is getting changed so in run script activity how can we set it dynamically
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 02:55 AM
Hi,
As I mentioned please don't use current.update()
Now are you using correct sys_id and correct variable name there i.e. variablename1
Did you check that variable value is empty or not
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 12:08 AM
Way 1 :
var text = 'Setting Description';
var gr = new GlideRecord('sc_request');
if(gr.get(current.change.sys_id)){ // Here change should be your reference field on request
gr.description = text;
gr.update();
}
Way 2 :
var gr = new GlideRecord('sc_request');
gr.addQuery(current.request);
gr.query();
if (gr.next())
{
gr.short_description = current.cat_item.short_description;
gr.description = current.cat_item.description;
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 12:14 AM
Hi,
You can verify the catalog item and set the description as
Assuming your wf is set on sc_req_item table.
if(current.cat_item=='sys_id of catalog item')
{
current.description='ABC';
current.update();
}
if(current.cat_item=='sys_id of 2 catalog item')
{
current.description='ABC';
current.update();
}
Or
if you want to set the description from the description of catalog item.
current.description=current.cat_item.description;
current.update();
Thanks,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 12:15 AM
Hi,
If same workflow is attached to multiple catalog items then in run script you can determine what is the catalog item name and based on that set the description
var itemName = current.cat_item.name;
if(itemName == 'Raise Hardware Request'){
current.description = 'Your Description';
}
if(itemName == 'Raise Software Request'){
current.description = 'Your Another Description';
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 12:22 AM
this is the code which am using in run script
answer = desc();
function desc() {
if (current.cat_item == 'sys id of catalog item') {
current.description = current.variables.variablename1.toString();
}
else if (current.cat_item == 'another sys id'){
current.description = current.variables.variablename2.toString();
}
current.update();
}