- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 06:07 AM - edited 08-02-2023 09:31 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 05:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 06:07 AM - edited 08-02-2023 09:31 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2023 09:42 AM
Thanks I like that idea even better! Much appreciated!