Unable to convert sys_id into Names. Help!!!

Pankhil
Tera Expert

Unable to convert sys_id into Names. Help!!!

Current codes works and returns 

find_real_file.png

When the line in orange is enabled.

find_real_file.png

But the underlying function does run Scripts-Background. 

find_real_file.png

find_real_file.png

function onChange(control, oldValue, newValue, isLoading) {

var access = g_form.getReference('access_level', getAccess);
function getAccess(access)
{
g_form.setValue('time_spec_group',access.time_spec_group);
//g_form.setValue('access_approver',getApprovers(access.access_approvers));
g_form.setValue('access_approver', access.access_approvers);
}


}

function getApprovers(List){
var outString = [];
for(i=0;i < List.length; i++)
{
var user = new GlideRecord('sys_user');
if(user.get(List[i]))
{
var username = user.name;
outString.push(username);
}
}
return outString;
}

1 ACCEPTED SOLUTION

Pankhil
Tera Expert

Ended up going with GlideAjax

Script Include

find_real_file.png

 

Catalog Client Script 

find_real_file.png

View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

Writing glide record in client script is not good practice, I would suggest use client callable script include and use glide ajax to execute your script include to get the data. 

 

Reference:

 

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/reference...

Vikas-Malhotra
Mega Guru

Hi,

 

have you tried this: g_form.setValue('access_approver',getApprovers(access.access_approvers.toString()));

Priyanka SHIND2
Mega Guru

Hello,

In your function getApprovers(), edit with 

return outString.toString();

Please mark my answer correct/helpful if it helped you in any way.

Thank you

Pankhil
Tera Expert

Ended up going with GlideAjax

Script Include

find_real_file.png

 

Catalog Client Script 

find_real_file.png