Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 05:46 AM
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()
Solved! Go to Solution.