We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Change UI action button label

XYD23
Tera Contributor

I have a UI action named "Create ID", now I just need to change the display name to "Generate ID" without altering the UI action name field.

is there any methods to do?

9 REPLIES 9

Not recommended way but you can try below:

https://www.servicenow.com/community/developer-forum/how-to-dynamically-change-the-title-of-a-ui-act...

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Dr Atul G- LNG
Tera Patron

Hi @XYD23 

 

Atlast it will store in Name field only. So better change the name.

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Can you help me lets try it once?

 

Hi @Anil Lande  need your coding skill here.

 

 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

James Bustard
Tera Expert

While it's not a great idea, this is absolutely achievable without messing about with a script include which was mentioned elsewhere in this thread.

For example, in our instance we've added a u_approval_type field to the sysapproval_approver table. In it we have types such as 'endorsement', or 'approval'. Our business case was to change the label of the Approve button to Endorse, should the approval type be an endorsement. They also wanted the 'Reject' button to say 'Not Endorsed'.

We could create new buttons and show them on the form using the condition logic on the UI Action, then hide the buttons we don't want, or we can simply change the label.

As the u_approval_type field is not showing on the form itself, we added it to the scratchpad so it can be referenced in an onLoad client script.

E.g. Display Business Rule on the approval table: g_scratchpad.approvalType = current.getValue('u_approval_type');

You then need to get the button id of the UI Action. While looking at an approval, open the browser's Dev Tools and inspect the element. You'll find the sys_id there, along with the ID (as we had a view which only showed the bottom buttons our IDs reflected this).

The code we used in the onLoad client script is:

function onLoad() {
    var approvalType = g_scratchpad.approvalType;
    
    if (approvalType === 'endorsement') {
        var approveBtn = document.getElementById('approve_bottom');
        var rejectBtn = document.getElementById('reject_bottom');
        
        if (approveBtn) approveBtn.textContent = 'Endorse';
        if (rejectBtn) rejectBtn.textContent = 'Not Endorsed';
    }
}