How to display a Reference variable as "Last Name First Name" in a Record Producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I have a Reference variable in a Record Producer that points to the sys_user table.
Currently, the selected user is displayed as:
Ahnaf Sheik
However, I want it to be displayed in the following format:
Sheik Ahnaf (Last Name First Name)
The variable label is already "Report Entered By (Last Name, First Name)", but the reference field still displays the user's display value (First Name Last Name).
Is there a way to configure the reference variable or reference qualifier so that the selected value is displayed as Last Name First Name instead of First Name Last Name? Is this possible without changing the global display value of the sys_user table?
Any suggestions or best practices would be appreciated.
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @SatyamS81441163 ,
Yes this can be done using client script + glide ajax :
client script (onchange) :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('setName');
ga.addParam('sysparm_name', 'getFormattedName');
ga.addParam('sysparm_user_id', newValue);
ga.getXMLAnswer(function(displayName) {
g_form.setValue('user', newValue, displayName);
});
}
Script Include :
var setName = Class.create();
setName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFormattedName: function() {
var userId = this.getParameter('sysparm_user_id');
var gr = new GlideRecord('sys_user');
if (gr.get(userId)) {
return gr.getValue('last_name') + ' ' + gr.getValue('first_name');
}
return '';
},
type: 'setName'
});
So this will setting the name as per in your desired format :
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
That good but after submitting the form on native/backend view it is showing the previous format only like first name last name instead of that it must store Last name first name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
yes as the "Sheik Ahnaf" you saw earlier was just a temporary label shown, not something written to the database. So once the form is submitted, the field is still a reference to sys_user. Every time it's displayed after that in backend the platform re-resolves the display value directly from sys_user's dictionary, which is "First Last."
That's why it reverts the underlying data was always stored normally.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Yes, it get it, Thanks but How can store this in same format in database which eventually show in the native view