Converting User SysID to Display Name

AdamRich
Tera Expert

Hello all!

 

I had an issue earlier and came up with a better solution than the one I was initially found, so I wanted to share it.

 

The issue came about where my scripting was getting large as we define custom descriptions based on variables that come out of record producer so I wanted a way to write my code once with the ability to reuse it. The solution I went with was adding the following at the bottom of my script so that I can call it when I need to convert user sys ID's to their Display names. I hope this helps!

 

//Function use
current.short_description = "Separation of " + userDisplayName(producer.sep_SeparatingUser) + " was requested by " + userDisplayName(current.caller_id) + " effective " + producer.sep_Effective;

//Reusable function to convert 'sys_user' records to their display name.
function userDisplayName(user) {
	var user2 = new GlideRecord('sys_user');
	user2.get(user);
	var user2Name = user2.getDisplayValue();
	return user2Name;
}

 

#Utah #RecordProducer #ReusableFunction #sys_user #getDisplayValue()

1 ACCEPTED SOLUTION

VaishnaviShinde
Kilo Sage

Hello @AdamRich 

 

Instead of writing the function in record producer you can write that function in script include and then use that script include in any record producer. 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

 

View solution in original post

3 REPLIES 3

Samaksh Wani
Giga Sage
Giga Sage

Hello @AdamRich 

 

 

current.short_description = "Separation of " + userDisplayName(producer.sep_SeparatingUser.name) + " was requested by " + userDisplayName(current.caller_id.name) + " effective " + producer.sep_Effective;

 

 

Do not use function use above script to get display name in short description.

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

 

VaishnaviShinde
Kilo Sage

Hello @AdamRich 

 

Instead of writing the function in record producer you can write that function in script include and then use that script include in any record producer. 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

 

Thanks I like that idea even better! Much appreciated!