Change Management

shatakshi10
Tera Contributor

After the change has left the 'New' state make the following fields read-only on the change task if the user does not have the 'change_manager' or 'admin' roles
- Affected CI
- Priority
- Due Date
- Change Request
- Assignment Group
- Assigned To

12 REPLIES 12

Tried using UI Policy but it didnt worked, used g_user function in UI policy script

Moin Kazi
Kilo Sage
Kilo Sage

Hi @shatakshi10 ,

 

You need to retrieve data from the server side because the change request state is only stored there.

Please follow the steps below to achieve this:

1. Write an onLoad client script for the task table.

 

function onLoad() {
    var ga = new GlideAjax('ChangeRequestState');
    ga.addParam('sysparm_name', 'getState');
    ga.addParam('sysparm_change', g_form.getValue('change_request'));
    ga.getXMLAnswer(getCall);

    function getCall(response) {
        if (response != '-5' && !g_user.hasRole('change_manager') && !g_user.hasRole('admin')) {
           // It’s essential to mark the first field as not mandatory, as mandatory fields cannot be set to read-only.
            g_form.setMandatory('cmdb_ci', false);
            g_form.setMandatory('priority', false);
            g_form.setMandatory('assignment_group', false);
            g_form.setMandatory('assigned_to', false);
            g_form.setReadOnly('cmdb_ci', true);
            g_form.setReadOnly('priority', true);
            g_form.setReadOnly('assignment_group', true);
            g_form.setReadOnly('assigned_to', true);
        }
    }
}

 

 

2) Write a client callable script that includes the role for public access, allowing anyone to access it.

 

var ChangeRequestState = Class.create();
ChangeRequestState.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getState: function() {

        var change_id = this.getParameter('sysparm_change');
        var changeGR = new GlideRecord('change_request');
        changeGR.get(change_id);
        return changeGR.state;
    },
    type: 'ChangeRequestState'
});

 

 

Output :

MoinKazi_0-1729672654264.png

 

Hope this help you.

 

Regards

Moin

shatakshi10
Tera Contributor

Users without the 'change_manager' or 'admin' roles should also not have an 'Edit' button on the 'Affected CIs' related list on the change task record once the new state has left.

You can configure all list-related functionality through list control. This includes role-based buttons, filters, links, and much more. Just visit list control to access a variety of features.

 

If you want the New and Edit buttons to be visible only to users with the admin or change_manager roles, please refer to the image provided.

MoinKazi_1-1729767964680.png

 

 

To open list control for a specific related list, follow the steps below:

 

Go to Specific Related List > Right Click On any Column > Configure > List Control

MoinKazi_0-1729767901229.png

 

Thanks,

Moin

 

Users without the 'change_manager' or 'admin' roles should also not have an 'Edit' button on the 'Affected CIs' related list on the change task record once the new state has left.