UI action configuration on SOW view

AkshitG90438384
Mega Contributor

Hi Fellas, 

 

I hope you all are doing well. 

I am recently stuck with a requirement and would love some insights, solutions on it. 

 

There are UI actions on Change Request that are Close or Request Approval. Requirement was to make those button disabled if the assignment group is SAP and the logged in user is not Angela. 

If the logged in user is Angela and assignment group is SAP so she can access those UI actions to change the states of the Change Request. 

 

It was easy to configure UI actions for native view but when it comes to SOW view (I am finding hard time) 

I will attach screenshots and scripts for the reference. 

 

Screenshot 2026-09-30 114242.pngScreenshot 2026-09-30 114202.pngScreenshot 2026-09-30 114110.png

 

The scripts Im using for Close UI action is

function moveToClosed() {
    if (g_user.hasRole('admin')) {
        g_form.setValue("state", "3");
        gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
        return;
    }
    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {
            return false;
        }
    }
    g_form.setValue("state", "3");
    gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");

}

if (typeof window == 'undefined')
    setRedirect();

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}

addLoadEvent(function() {
    if (g_user.hasRole('admin')) {
        return;
    }

    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {
            var button = document.getElementById('state_model_move_to_closed');
            if (button) {
                button.disabled = true;
				button.style.backgroundColor = '#d3d3d3';
				button.style.color = '#666666';
				button.style.borderColor = '#b5b5b5';
                button.style.cursor = 'not-allowed';
            }
        }
    }
});

For request approval 1

function moveToAssess() {
    if (g_user.hasRole('admin')) {
        g_form.setValue("state", "-4");
        gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
        return;
    }
    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {
            return false;
        }
    }
	
    g_form.setValue("state", "-4");
    gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
}

if (typeof window == 'undefined')
    updateAndRedirect();

function updateAndRedirect() {
    current.update();
    action.setRedirectURL(current);
}

addLoadEvent(function() {
    if (g_user.hasRole('admin')) {
        return;
    }

    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {
            var button = document.getElementById('state_model_request_assess_approval');
            if (button) {
                button.disabled = true;
				button.style.backgroundColor = '#d3d3d3';
				button.style.color = '#666666';
				button.style.borderColor = '#b5b5b5';
                button.style.cursor = 'not-allowed';
            }
        }
    }
});

 

For request approval 2

function moveToAuthorize() {
    if (g_user.hasRole('admin')) {
        g_form.setValue("state", "-3");
        gsftSubmit(null, g_form.getFormElement(), 'state_model_request_cab_approval');
        return;
    }
    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {    
            return false;
        }
    }
    g_form.setValue("state", "-3");
    gsftSubmit(null, g_form.getFormElement(), 'state_model_request_cab_approval');
}

if (typeof window == 'undefined')
    updateAndRedirect();

function updateAndRedirect() {
    current.update();
    action.setRedirectURL(current);
}

addLoadEvent(function() {
    if (g_user.hasRole('admin')) {
        return;
    }

    if (g_form.getValue('assignment_group') == 'a7c1b92e1bab3110ad0a20a2b24bcb47') {
        if (g_user.userID != '46776fc81b5c4210ad0a20a2b24bcb35') {
            var button = document.getElementById('state_model_request_cab_approval');
            if (button) {
                button.disabled = true;
				button.style.backgroundColor = '#d3d3d3';
				button.style.color = '#666666';
				button.style.borderColor = '#b5b5b5';
                button.style.cursor = 'not-allowed';
            }
        }
    }
});

 

Thanks a lot for your time 🙂 

-AK

6 REPLIES 6

Tanushree Maiti
Tera Patron

Hi @AkshitG90438384 

 

Could you please explain why  “Close” or “Request Approval” is not required for your SAP  business

For a Change Request in ServiceNow, the “Close” or “Request Approval” UI actions are typically required to control the change lifecycle and ensure proper governance.

 

Does it mean for  "assignment group is SAP and the logged in user is not Angela" - OOB governance set up not needed?

 

 Also plz  check this KB for troubleshooting the issue : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1811593

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

AkshitG90438384
Mega Contributor

Hi Tanushree,

Thank you for your response.

Angela is part of the SAP group. She noticed that other team members were closing changes or requesting approvals without properly reviewing them.

As a result, she introduced a requirement that only she can request approvals or close the change.

 

So whenever a change is created for SAP group. Only she can request approvals or close the changes. For other teams members the button must look disabled.