- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2025 06:46 AM
The final wording of my short description text is not working, and I was hoping for some guidance on where I am going wrong with it
// Set values for the task in this script. Use the variable 'task' when setting additional values.
// Note: This script is run after the task values are set using the Fields, Template or Values you have specified.
//
// For example:
var type = '';
var dept = current.variables.department;
switch (dept){
case "bid_strategy":
type = current.variables.bid_strategy_type.getDisplayValue();
break;
case "commercial":
type = current.variables.commercial_request_type.getDisplayValue();
break;
case "contracts":
type = current.variables.contracts_request_type.getDisplayValue();
break;
case "executive":
type = current.variables.executive_request_type.getDisplayValue();
break;
case "fps":
type = current.variables.fps_request_type.getDisplayValue();
break;
case "marketing":
type = current.variables.marketing_request_type.getDisplayValue();
break;
case "pricing":
type = current.variables.pricing_request_type.getDisplayValue();
}
task.short_description = "RevOps Support Request - "+current.variables.requested_for.name +" - "+current.variables.department.getDisplayValue() +" - "+type;
The +type at the end is not working, and just coming back blank. What am I doing wrong, and what is the best way to fix? Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2025 08:21 AM
try this
switch (dept + ''){
OR
use this
var dept = current.variables.department.toString();
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
‎03-21-2025 08:56 AM
current.variables.department doesn't give you string, so adding that '' makes that object as string and then it can be compared in switch
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader