In Change Table, Field should be mandatory and visible only to Change Manager in New State.

Not applicable

In Change Table, Field should be mandatory and visible only to Change Manager in New State.

6 REPLIES 6

Not applicable

Hi @Community Alums ,

You can use a UI policy to set the fields mandatory and visible , then  use the run scripts option like below:

 

 

function onCondition() {

if(!g_user.hasRoleExactly('change_manager')) {
	g_form.setReadOnly('<name_of_field>', true);
}

}

 

 

Not applicable

No Luck, Not sure what's the issue though.

Dr Atul - LNG
Tera Patron

Hi @Community Alums 

You didn’t specify which field should be mandatory and why, specifically for the Change Manager. You can follow the UI policy as suggested by @Sandeep Dutta . Also, since it is mandatory only for the Change Manager, make sure that the field is visible in the new state.

Ankur Bawiskar
Tera Patron

@Community Alums 

you can use onLoad client script for this

function onLoad() {
    var isChangeManager = g_user.hasRoleExactly('change_manager');
    var currentState = g_form.getValue('state');
    var fieldName = 'your_field_name'; // Replace with your actual field name

    if (currentState.toString() == '-5') { // Assuming 'New' state value is '-5'
        g_form.setVisible(fieldName, isChangeManager);
        g_form.setMandatory(fieldName, isChangeManager);
    } else {
        g_form.setVisible(fieldName, true);
        g_form.setMandatory(fieldName, false);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.