- 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 04:30 AM
Hi @Atik
Greetings!!
I am not sure, we can add these variables in Task Description and if yes it required a good code to concatenate and show. We can show variable on task OOTB as per my understanding.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2023 04:32 AM
Hi,
In the workflow you can create a script activity, in the script you can check the catalog item, and based on the catalog item you can update the Description
Regards,
Piyush Sain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2023 04:59 AM
Hi Piyush,
Can you help me with the code please
Thanks
Atik
- 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;