- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:18 AM
Hi Team,
Can someone please help me on this.
Requirement: In the select server name variable which ever ci is selected need to visible that ci name in the SCTASK short description. I have written code but it is giving sys_id. i need server name.
As seen in the below screenshot it is giving the sys_id of the server in the select server name.
I need server name in the short description.
Script:
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + current.variables.select_server_name;
var selectAsset = current.variables.select_the_asset;
if (selectAsset == 'E&G') {
task.assignment_group = '48542266dbae9bc42ffff06dbf9619a0';
} else if (selectAsset == 'MinAu_IT') {
task.assignment_group = 'a844d7901b7bd8101e66a8a13d4bcbd6';
} else if (selectAsset == 'MinAu_OT') {
task.assignment_group = '44542266dbae9bc42ffff06dbf96199e';
} else if (selectAsset == 'MinAm_IT') {
task.assignment_group = '60e438ccdb6e68103a2c907cd396195e';
}
current.update();
Please help me on this requirement.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:41 AM
Hello @nikhitha24 ,
You can give a try to the script below and modify it further as per your further needs.
// Get the server name from the reference field 'select_server_name'
var serverName = current.variables.select_server_name.getDisplayValue();
// Update the short description with the server name
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + serverName;
// Set assignment group based on selectAsset
var selectAsset = current.variables.select_the_asset;
if (selectAsset == 'E&G') {
task.assignment_group = '48542266dbae9bc42ffff06dbf9619a0';
} else if (selectAsset == 'MinAu_IT') {
task.assignment_group = 'a844d7901b7bd8101e66a8a13d4bcbd6';
} else if (selectAsset == 'MinAu_OT') {
task.assignment_group = '44542266dbae9bc42ffff06dbf96199e';
} else if (selectAsset == 'MinAm_IT') {
task.assignment_group = '60e438ccdb6e68103a2c907cd396195e';
}
// Update the task
current.update();
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:29 AM
Hi @nikhitha24
As the select the server name is the reference field, use the below code to set SD
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + current.variables.select_server_name.getDisplayValue();
OR
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + current.variables.select_server_name.name; // if you dot walk the referenced table there must be field indicating name
Please hit helpful if this resolves your query
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:33 AM
Hi @nikhitha24
Try the below
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + current.variables.select_server_name.name;
current.variables.select_server_name - Brings the sys_id from the variable to convert try the above line
Thanks,
Mounish.CH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:41 AM
Hello @nikhitha24 ,
You can give a try to the script below and modify it further as per your further needs.
// Get the server name from the reference field 'select_server_name'
var serverName = current.variables.select_server_name.getDisplayValue();
// Update the short description with the server name
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + serverName;
// Set assignment group based on selectAsset
var selectAsset = current.variables.select_the_asset;
if (selectAsset == 'E&G') {
task.assignment_group = '48542266dbae9bc42ffff06dbf9619a0';
} else if (selectAsset == 'MinAu_IT') {
task.assignment_group = 'a844d7901b7bd8101e66a8a13d4bcbd6';
} else if (selectAsset == 'MinAu_OT') {
task.assignment_group = '44542266dbae9bc42ffff06dbf96199e';
} else if (selectAsset == 'MinAm_IT') {
task.assignment_group = '60e438ccdb6e68103a2c907cd396195e';
}
// Update the task
current.update();
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 05:45 AM
Hello @nikhitha24
As developers, optimizing code for maintainability is crucial. Storing SYS_IDs in a System property enhances flexibility, enabling non-technical users to manage server and assignment group configurations easily. This approach facilitates future adjustments without code changes, promoting adaptability to evolving business needs.
You can give a try to my updated script and check screenshot below and modify it further as per requirement.
var serverName = current.variables.select_server_name.getDisplayValue();
task.short_description = "ABAP | " + current.variables.what_type_of_restoration_do_you_need + " | " + serverName;
var selectAsset = current.variables.select_the_asset;
var assetToSysIdMap = JSON.parse('your.system.property.name');
for (var asset in assetToSysIdMap) {
if (selectAsset == asset) {
task.assignment_group = assetToSysIdMap[asset];
break;
}
}
current.update();
System Property :
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Warm Regards,
Subhashis r7