Javascript - User Name display

Cindy V
Kilo Contributor

I have created a record producer with questions for our Service Catalog. It creates an incident and the answers to the questions are displayed in the incident description. I have a question of who to contact that is a list collector so multiple users can be selected.

My question is how to display the user name in the description field. I have the following coded:

'\nWho may we contact for more information? | ' + producer.u_contact 

With this code, what displays is the sys_id for the user and I need it to show the user name instead.

Can someone tell me how to get this to work?

Thanks.

1 ACCEPTED SOLUTION

Cindy V, 

You can add the function where you are using the line 

'\nWho may we contact for more information? | ' + sysIdToUserId(producer.u_contact)

I also see that you figured out something on your own, which is good. 

Just to clarify why I suggested you to use a function like that is for below reasons 

1. The below code is wrong, you will get undefined as the return value not the User ID's

producer.u_contact.getDisplay();

2. The below code is right, probably the shortest way to do it

producer.getDisplayValue('u_contact');

3. The code in the above step will spit out the Display Value of the Sys_User table[which may not be the UserID all the time]. So you need a function that will return all the UserIDs explicitly. 

-Please mark my answer as helpful/correct if applicable. Or else please dont 🙂

View solution in original post

8 REPLIES 8

Yup, typo.  Should have been "getDisplayValue()".   😞

Cindy V, 

You can add the function where you are using the line 

'\nWho may we contact for more information? | ' + sysIdToUserId(producer.u_contact)

I also see that you figured out something on your own, which is good. 

Just to clarify why I suggested you to use a function like that is for below reasons 

1. The below code is wrong, you will get undefined as the return value not the User ID's

producer.u_contact.getDisplay();

2. The below code is right, probably the shortest way to do it

producer.getDisplayValue('u_contact');

3. The code in the above step will spit out the Display Value of the Sys_User table[which may not be the UserID all the time]. So you need a function that will return all the UserIDs explicitly. 

-Please mark my answer as helpful/correct if applicable. Or else please dont 🙂

Cindy V
Kilo Contributor

Never mind, I figured out that the function is added to the script of the record producer.

THANK YOU VERY MUCH FOR THIS INFORMATION!!!!

Cindy V,

is your question answered ? if its not answered then please let us know your additional questions. 
If it is answered, then please close this thread by marking the appropriate answer as Correct. This way others might find this thread helpful in future. Also, please mark the appropriate answers as Helpful if applicable.
Thank you,
Aman Gurram