- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 04:25 AM - edited 11-08-2023 04:32 AM
Hi All,
I am working on workflows, As i have a requirement that i need to update the catalog task description with the catalog item form variables(Requested Item) values,
But my concern is, there are 8 catalog items and we are using the same workflow for all of them and for 8 catalog items there are different variables.
So how can achieve this? is it feasible in ServiceNow? or i need to create different workflows for all the 8 catalog items?
Please help
Thanks and Regards,
Atik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:22 AM
We have been using the following script for many years:
var str = '';
var variables = current.variables.getElements();
for (var i=0;i<variables.length;i++) {
var v = variables[i].getQuestion();
if(v.getLabel() != '' && v.type != 14) { //Do not show macros (type 14)
str += v.getLabel() + ": " + v.getDisplayValue() + "\n";
}
}
current.description = str;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:52 AM
let same workflow be used for different catalog items.
you can use this script to populate the variable values in catalog task description inside the Catalog task activity Advanced script
You need to enhance it to handle MRVS if you are using it in any of your catalog items
var arr = [];
var variables = current.variables.getElements();
for (var i=0;i<variables.length;i++) {
var v = variables[i].getQuestion();
if(v.getLabel() != '' && v.getDisplayValue() != '' && v.type != 14) {
var str = v.getLabel() + ": " + v.getDisplayValue();
arr.push(str);
}
}
task.description = arr.join('\n');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:57 AM
Thank you so much it exactly meet my requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 04:37 AM
Hi Atik,
If you want to update the description only for a specific catalog item then you should just put that condition into an if condition stating that if item is this then only update the description.
On RITM, Item field contains the value of Catalog item. So you just need to compare item field with sys_id of the catalog item that you want to update for.
I hope my answer helps. If it does please mark it correct.
Thanks,
Utpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 05:52 AM
let same workflow be used for different catalog items.
you can use this script to populate the variable values in catalog task description inside the Catalog task activity Advanced script
You need to enhance it to handle MRVS if you are using it in any of your catalog items
var arr = [];
var variables = current.variables.getElements();
for (var i=0;i<variables.length;i++) {
var v = variables[i].getQuestion();
if(v.getLabel() != '' && v.getDisplayValue() != '' && v.type != 14) {
var str = v.getLabel() + ": " + v.getDisplayValue();
arr.push(str);
}
}
task.description = arr.join('\n');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader