Variable value is displaying the sys id

Cupcake
Mega Guru

I have a catalog item in which the user selects a drive (from a reference) and then I have a script to pull back the owner of the drive but it is giving the sys id vs the value. This information is on the cmdb table. I know that I should be able to make the display = true for one of those fields on the table, but because it is the storage file share there are securities which is locked and don't allow me to change the display.

I was told that I could use the getDispaly value, but I am not sure how to do this. I have a catalog client script where I am pulling back the current owner (see below). Not sure where to add this getDisplay value.

 

function onChange (control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue("current_owner", ""); 
return;
}

var cmdb_ci_storage_fileshare = g_form.getReference('variable name',CallBack); 
}

function CallBack(cmdb_ci_storage_fileshare) {
g_form.setValue("current_owner", cmdb_ci_storage_fileshare.owned_by); // single line text field


}

find_real_file.png

 

Thank you.

 

8 REPLIES 8

mmaraj1
Mega Expert
function onChange (control, oldValue, newValue, isLoading) {
if (newValue == '') {
g_form.setValue("current_owner", ""); 
return;
}

var cmdb_ci_storage_fileshare = g_form.getReference('variable name',CallBack); 
}

function CallBack(cmdb_ci_storage_fileshare) {
g_form.setValue("current_owner", cmdb_ci_storage_fileshare.owned_by.getDisplayValue()); // single line text field


}

I added the getDisplayValue()); and now the result is empty

I don't even get the sysid.

 

ServiceNowSteve
Giga Guru

try changing

g_form.setValue("current_owner", cmdb_ci_storage_fileshare.owned_by);

to

g_form.setValue("current_owner", cmdb_ci_storage_fileshare.owned_by.name);

When I added the owned_by.name I received the below

 

find_real_file.png