How to Display UI action button via script

Suyash Joshi
Tera Contributor

Hello Everyone,

I need a small requirement on UI action.
I need to display form button via UI action script or Client script if caller is in the given group. Although I create a new group.
My script:-

    var callerValue = g_form.getValue('u_caller');
    if (g_user.hasRole(callerValue)) {
        g_form.removeDecoration('form_button');
    } else{
        g_form.addDecoration('form_button');
    }
Any help will be grateful
Thank You
Regards,
Suyash
1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @Suyash Joshi 

 

Please have a look on the below posts :

https://www.servicenow.com/community/itsm-forum/show-ui-action-button-based-on-logged-in-users-assig...

https://www.servicenow.com/community/developer-forum/ui-action-button-visible-only-to-people-of-a-sp...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

Amit Verma
Kilo Patron
Kilo Patron

Hi @Suyash Joshi 

 

Please have a look on the below posts :

https://www.servicenow.com/community/itsm-forum/show-ui-action-button-based-on-logged-in-users-assig...

https://www.servicenow.com/community/developer-forum/ui-action-button-visible-only-to-people-of-a-sp...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Harish KM
Kilo Patron
Kilo Patron

Hi @Suyash Joshi You can use condition of the UI Action for the button to be visible, like below

gs.getUser().isMemberOf('Group Name') // mention the group name, if loggedin user is member of grp , then button will be visible

HarishKM_0-1705472986562.png

 

Regards
Harish

Should I have to run script too condition is not working.

Hi @Suyash Joshi 

 

Please try removing the script and keep only the condition. It should work.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.