Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Client Side - UI Action

KeerthiPraV
Tera Contributor

I have a use case where I need to use the getReference() method to retrieve the manager's name from the assignment group reference field. When I click a UI Action button on the client side, I want to display the manager's name in a popup alert. Could you provide the correct approach that uses the getReference() method to achieve this?

2 ACCEPTED SOLUTIONS

brianlan25
Kilo Patron

What have you tried?

View solution in original post

Ankur Bawiskar
Tera Patron

@KeerthiPraV 

you can use getReference() with callback or use GlideAjax

what you tried and what didn't work?

what debugging did you do?

see this

GlideAjax Example Cheat Sheet (UPDATED) 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

brianlan25
Kilo Patron

What have you tried?

Yes, I have tried this. But i want to fulfill the requirement within the Client - UI action script only.

showManagerName() {
    var groupSysId = g_form.getValue('assignment_group');

    if (!groupSysId) {
        alert("No Assignment Group selected!");
        return;
    }

    g_form.getReference('assignment_group', function(gr) {
        if (gr.manager) {
            var managerName = gr.manager.getDisplayValue();
            alert("Manager Name: " + managerName);
        } else {
            alert("This group does not have a manager assigned.");
        }
    });
}

I have tried like this...But it's not getting manager name.
If I use Glide Ajax & Script include its working fine.
but I want to try it from client side only.
Could you help me out with this.

Ankur Bawiskar
Tera Patron

@KeerthiPraV 

you can use getReference() with callback or use GlideAjax

what you tried and what didn't work?

what debugging did you do?

see this

GlideAjax Example Cheat Sheet (UPDATED) 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

I have tried gerReference() method and Glide ajax Too.
Glide Ajax is working fine. But i want to implement with only Client - UI action script.

showManagerName() {
    var groupSysId = g_form.getValue('assignment_group');

    if (!groupSysId) {
        alert("No Assignment Group selected!");
        return;
    }

    g_form.getReference('assignment_group', function(gr) {
        if (gr.manager) {
            var managerName = gr.manager.getDisplayValue();
            alert("Manager Name: " + managerName);
        } else {
            alert("This group does not have a manager assigned.");
        }
    });
}
I have tried this code. But it's not working.
Could you please guide me to implement the use case only with client-side script.