The CreatorCon Call for Content is officially open! Get started here.

How to restrict "complete" button on problem table to a particular group only

Nandini DM
Tera Contributor

Hi ,

I want to restrict "Complete" button on problem table to a particular group , if somebody who is not part of group click on the button user should get error message .

Below is the OOB code:

function onComplete() {
    if (!g_form.hasField("state") || !g_form.hasField("resolution_code")) {
        getMessage('Cannot complete the Problem as atleast one of the following fields are not visible: \'State\' \'Resolution code\'', function(msg) {
            g_form.addErrorMessage(msg);
        });
        return false;
    }

    g_form.setValue("state", g_scratchpad.STATE.CLOSED);
    g_form.setValue("resolution_code", g_scratchpad.RESOLUTION_CODES.FIX_APPLIED);
    g_form.save();
}
 
Please help me!
2 REPLIES 2

Anirudh Pathak
Mega Sage

Hi @Nandini DM ,

You can just hide the button from the users who are not part of the group using the below code.

Put this code in the condition field of the UI Action, if there is already another condition present for that UI Action just put "&&" after that condition and use the below code - 

gs.getUser().isMemberOf('YourGroupName');

 

Nandini DM
Tera Contributor

Hi @Anirudh Pathak 
my requirement is not to hide button, if user is not part of group error message should pop up.