convert sys id

Yuval Lanton
Tera Contributor

Hi.

I am trying to auto populate the 'Previously assigned to' field with the value of the 'Assigned to' field , but i get only sys id.

How do I convert the sys id to the value I need?

1 ACCEPTED SOLUTION

If you are using server script then and you don't want reference field then use below logic.

 current.u_previously_assigned_to = current.assigned_to.name;

or 

current.u_previously_assigned_to = current.assigned_to.getDisplayValue();

View solution in original post

7 REPLIES 7

Shekhar Navhak1
Kilo Sage
Kilo Sage

can You please post your code here?

Please mark the answer correct/helpful based on Impact.
Regards, Shekhar

Basheer
Mega Sage

Hi @Yuval Lanton ,

The Assigned to is referenced to the sys_user table and if you access it you would get the sys_id of that user record.

If you want its full details then you need to do as below at server level

var assignedTo = current.assigned_to;
var userRecord = new GlideRecord("sys_user");
if(userRecord.get(assignedTo)){
current.previous_assigned_to = userRecord.name; //If you want name to be populated.
//Fill in what ever you need from the userRecord object
}
 

  If you want at client level you need to do Client Script + Display BR (or) client script + Script include.

Let me know if you want more details on how to do via client side.

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Shashank_18
Mega Guru

use getDisplayValue() to show the display value of that reference field.

example : current.assigned_to.getDisplayValue();

Teju Dhoran
Kilo Sage
Kilo Sage

Hi,

I guess your firld 'Previously assigned to' is of type string. Change type to reference and use sys_user table as reference table.