Make fields readonly and also editable on clicking UI action

maneesh3
Tera Contributor

Hi Team,

 

Need help in following requirement:

 

Make fields read-only (Assigned To and Assignment group) once filled in Case form and once users click on Transfer button, then Assigned To and Assignment group editable so that users can transfer ticket to other team.

 

I have written UI policy and UI action and assuming because of UI policy , UI action code not working to make fields editable.

Kindly suggest.

 

Thanks,

 

5 REPLIES 5

priyasunku
Kilo Sage

@maneesh3 

 

I think UI action executes first and UI policy next. so, you can add a condition in UI policy when it has to run and not conflict the Ui action code.

 

please refer the below link for execution order.

 

https://www.servicenow.com/community/developer-forum/order-of-execution-of-business-rules-ui-policy-...

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

@priyasunku 

 

Thanks for the reply. But I changed order of execution even It did not work.

1. I have written policy - if Assigned to is not empty-> make fields (Assigned To and Assignment group) read only

 

2. Written UI action : to make a field mandatory and also (Assigned To and Assignment group)  editable:

 

Mandatory condition is working but not Readonly condition.

 

 


function runClientCode(){

 

if(g_form.getValue('u_reason_for_transfer')==''){


g_form.showFieldMsg('u_reason_for_transfer','Reason for Transfer is Mandatory before transferring','error');

g_form.setMandatory('u_reason_for_transfer','true');
g_form.setReadOnly('assignment_group', 'false');

 

 

return false; //Abort submission


}

 

//Call the UI Action and skip the 'onclick' function


gsftSubmit(null, g_form.getFormElement(), 'submit_t_form'); //MUST call the 'Action name' set in this UI Action

current.update();
}

 

 

@maneesh3 

 

you can add more condition in UI policy where 'u_reason_for_transfer' is not empty then it should be read only. so i think in this way there will not be any conflict.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

@priyasunku 

 

It is working for one iteration, lets say people filled Reason to Transfer field and saved form , now again it they want to transfer the ticket, then once they click on button, it should clear the field and editable same way to enter new details

 

Thanks a lot