Converting sys_id to a value

Tim Wmson
Giga Expert

I'm creating a catalog item to ask the submitter what group they want a user added to. I have it working except it returns the   sys_ID of the group to the Incident summary field. How do I convert this to the group name?

1 ACCEPTED SOLUTION

Ahmed Drar
Tera Guru
Tera Guru

Hi , if you set the group's name as Display value then getDisplayValue() is the solution for you or you can try var gr = new GlideRecord('sys_user_group');   if (gr.get(groupID))// add group ID here {   // gr.name returns group's name }


View solution in original post

14 REPLIES 14

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Tim,



Use getDisplayValue() to get the display value of the group.


Hi I am unable to fetch the List Collector Display value  from Client Enabled UI Action, i have tried the below code but no luck.can anyone help me on this.

1.g_form.getValue('v_members'); showing sysid not display value.
2.g_form.getDisplayValue('v_members'); not showing anything.
3.gr.getDisplayValue('v_members); gr is not defined.

I am trying to Fetch the variable and include UI Macro Button on fiedl.can any one help me on this

function onLoad() {
try{
var field ='v_members';
var field = g_form.getControl(field);
$(field).insert({
after: '<a onclick="doSomething()" name="my_custom_macro" id="my_custom_macro"><img src="images/warning.gifx" alt="Show Macro" title="Show Macro" style="padding-right:4px"></a>'
});
}
catch(e){
alert('Error');
}
}

//onclick event to fire when the image is clicked
function doSomething() {
alert('You clicked me!');
}

 

I am getting undefined error. 'V_Members' is a variable type List Collector.

Ahmed Drar
Tera Guru
Tera Guru

Hi , if you set the group's name as Display value then getDisplayValue() is the solution for you or you can try var gr = new GlideRecord('sys_user_group');   if (gr.get(groupID))// add group ID here {   // gr.name returns group's name }