- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:14 AM - edited 11-21-2023 12:18 AM
Team,
I have a variable 'Choose one of the following' select box type variable having 3 options, for 2nd option 'To avail upgraded version of MSOffice', I want to display this option's sys_id In the short description of sc_task for which I am using a Catalog task activity contains below advanced script
current.state = 2; // Set RITM as WIP
task.assignment_group.setDisplayValue('Help Desk');
if ((current.variables.choose_one_of_the_following.getDisplayValue().indexOf('To avail upgraded version of MSOffice') > -1) && (current.variables.type_of_machine.getDisplayValue().indexOf('Physical') > -1)) {
task.short_description = 'Asset tag ID - ' + current.variables.asset_tag.getDisplayValue() + ' Machine type - ' + current.variables.type_of_machine.getDisplayValue() + ' Option is - ' + current.variables.choose_one_of_the_following.sys_id.toString();
} else {
task.short_description = 'No Asset tag ' + current.variables.type_of_machine.getDisplayValue();
}
task.approval = "Approved";
I have tested this, and display conditions are working fine, but don't know why sys_id is not getting populated in the Short description, I understand that line no. 4 below mentioned part needs to be modified in such a way so that it displays sys_id of the 2nd option on Short Description of sc_task
current.variables.choose_one_of_the_following.sys_id.toString();
I have used the below syntax but no luck yet,
current.variables.choose_one_of_the_following.sys_id.getValue();
or
current.variables.choose_one_of_the_following.getUniqueValue();
or (when using below syntax),
current.variables.choose_one_of_the_following.sys_id;
the short description populates as below
Kindly help to get this resolved
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:48 AM
Hi @rishabh31
Try the below script.
var option_sys_id = "";
var qGr = new GlideRecord("item_option_new");
qGr.addQuery("cat_item", current.cat_item);
qGr.addQuery("name", "choose_one_of_the_following");
qGr.query();
if(qGr._next()){
var cGr = new GlideRecord("question_choice");
cGr.addQuery("question", qGr.getUniqueValue());
cGr.addQuery("value", current.variables.choose_one_of_the_following);
cGr.query();
if(cGr._next()){
option_sys_id = cGr.sys_id + '';
}
}
current.state = 2; // Set RITM as WIP
task.assignment_group.setDisplayValue('Help Desk');
if ((current.variables.choose_one_of_the_following.getDisplayValue().indexOf('To avail upgraded version of MSOffice') > -1) && (current.variables.type_of_machine.getDisplayValue().indexOf('Physical') > -1)) {
task.short_description = 'Asset tag ID - ' + current.variables.asset_tag.getDisplayValue() + ' Machine type - ' + current.variables.type_of_machine.getDisplayValue() + ' Option is - ' + option_sys_id;
} else {
task.short_description = 'No Asset tag ' + current.variables.type_of_machine.getDisplayValue();
}
task.approval = "Approved";
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:30 AM
Hi Rishabh,
You need to GlideRecord sys_choice table to get the sys_id of the choice and then use that to populate short description.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:33 AM
@Jaspal Singh Sir, could you pls help with script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 12:48 AM
Hi @rishabh31
Try the below script.
var option_sys_id = "";
var qGr = new GlideRecord("item_option_new");
qGr.addQuery("cat_item", current.cat_item);
qGr.addQuery("name", "choose_one_of_the_following");
qGr.query();
if(qGr._next()){
var cGr = new GlideRecord("question_choice");
cGr.addQuery("question", qGr.getUniqueValue());
cGr.addQuery("value", current.variables.choose_one_of_the_following);
cGr.query();
if(cGr._next()){
option_sys_id = cGr.sys_id + '';
}
}
current.state = 2; // Set RITM as WIP
task.assignment_group.setDisplayValue('Help Desk');
if ((current.variables.choose_one_of_the_following.getDisplayValue().indexOf('To avail upgraded version of MSOffice') > -1) && (current.variables.type_of_machine.getDisplayValue().indexOf('Physical') > -1)) {
task.short_description = 'Asset tag ID - ' + current.variables.asset_tag.getDisplayValue() + ' Machine type - ' + current.variables.type_of_machine.getDisplayValue() + ' Option is - ' + option_sys_id;
} else {
task.short_description = 'No Asset tag ' + current.variables.type_of_machine.getDisplayValue();
}
task.approval = "Approved";
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 01:04 AM
Thank you @AnveshKumar M Sir, Understanding the script and it works amazingly. marked response correct and helpful.