How to display a Reference variable as "Last Name First Name" in a Record Producer?

SatyamS81441163
Tera Contributor

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.

Screenshot 2026-07-16 at 12.17.23 PM.png

 

7 REPLIES 7

yashkamde
Giga Sage

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 :

Screenshot 2026-07-16 123029.pngScreenshot 2026-07-16 123034.png

 

If my response helped mark as helpful and accept the solution.

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

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.

Yes, it get it, Thanks but How can store this in same format in database which eventually show in the native view