How to convert the server sys_id into the name in the catalog task description

nikhitha24
Tera Guru

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.

 

nikhitha24_0-1707469930782.png

As seen in the below screenshot it is giving the sys_id of the server in the select server name.

nikhitha24_1-1707470161716.png

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.

1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

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

View solution in original post

4 REPLIES 4

_Gaurav
Kilo Sage

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!
 

Mr_m1
Tera Expert

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

Aniket Chavan
Tera Sage
Tera Sage

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

Subhashis Ratna
Tera Guru

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 :

Subhashisr7_0-1707486136753.png

 


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