- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 09:33 PM
Hi All,
I need the Task short description to display depending on the "Type of Request" selected. The requirement is to ensure that both the "type of request" selected, the second variable + requestor's name reflect in the "Task short description".
Only need one to show in the task short description depending on the "type of request" NOT all three at once
See code below: How can I add the code to my catalog task activity and have it showing correctly in the Task Short description depending on the "type of request"?
task.short_description = current.variables.type_of_request + " - " + current.variables.alpha + " - " + current.variables.requested_for.name.toString();
task.short_description = current.variables.type_of_request + " - " + current.variables.bravo + " - " + current.variables.requested_for.name.toString();
task.short_description = current.variables.type_of_request + " - " + current.variables.charlie + " - " + current.variables.requested_for.name.toString();
Thank you for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 10:06 PM
Hi,
Can you share the script here?
sample script here; ensure you use proper value to compare from the type_of_request variable
var typeOfRequest = current.variables.type_of_request;
if(typeOfRequest == 'A'){
task.short_description = typeOfRequest + " - " + current.variables.alpha + " - " + current.variables.requested_for.name.toString();
}
else if(typeOfRequest == 'B'){
task.short_description = typeOfRequest + " - " + current.variables.bravo + " - " + current.variables.requested_for.name.toString();
}
else if(typeOfRequest == 'C'){
task.short_description = typeOfRequest + " - " + current.variables.charlie + " - " + current.variables.requested_for.name.toString();
}
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 09:39 PM
Hi there,
With this code, I guess you are only seeing the last one, is that correct? The one with "current.variables.charlie".
This is because you are overwriting the task.short_description everytime. Because you are using "task.short_description = ". If you would use "task.short_description +=" for example, it would be added on top of what has been set already in task.short_description.
Maybe something like this is already what you are after:
task.short_description = current.variables.type_of_request + " - " + current.variables.alpha + " - " + current.variables.requested_for.name.toString();
task.short_description += "\n" + current.variables.type_of_request + " - " + current.variables.bravo + " - " + current.variables.requested_for.name.toString();
task.short_description += "\" + current.variables.type_of_request + " - " + current.variables.charlie + " - " + current.variables.requested_for.name.toString();
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 09:43 PM
Thanks Mark. I will try it now and will let you know if it works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 09:53 PM
I tried it but its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 10:06 PM
Hi,
Can you share the script here?
sample script here; ensure you use proper value to compare from the type_of_request variable
var typeOfRequest = current.variables.type_of_request;
if(typeOfRequest == 'A'){
task.short_description = typeOfRequest + " - " + current.variables.alpha + " - " + current.variables.requested_for.name.toString();
}
else if(typeOfRequest == 'B'){
task.short_description = typeOfRequest + " - " + current.variables.bravo + " - " + current.variables.requested_for.name.toString();
}
else if(typeOfRequest == 'C'){
task.short_description = typeOfRequest + " - " + current.variables.charlie + " - " + current.variables.requested_for.name.toString();
}
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