Grayed out field along with UI action when user click on it.

coolsaurabh
Tera Contributor

Hi

I have created a UI action Locked and when user click on it two field of form (start_date and end_date)should be grayed out and this UI action button Locked out should also get grayed out.

But I observed that when I reload the form then this button and required field again come into editable mode.

I am using below script :-

function set(){

  g_form.setReadOnly('start_date', true);

  g_form.setReadOnly('end_date', true);

  document.getElementById("locked_out").disabled = true;

  }

I want that user can click on Locked bbutton only once and then after it becomes grayed out and start date and end date also remains grayed out. Even after reload form.

Thanks,

Sourabh

8 REPLIES 8

oharel
Kilo Sage

So add an onLoad script that works on a condition. For instance: if start_date and end_date are not empty, then all that you've written above.



function onLoad() {


  //Type appropriate comment here, and begin script below


  var start = g_form.getValue('start_date');


  var end = g_form.getValue('end_date');



  if(start !='' && end !='') {


  g_form.setReadOnly('start_date', true);


  g_form.setReadOnly('end_date', true);


  document.getElementById("locked_out").disabled = true;


  }


}



harel


Abhinay Erra
Giga Sage

I will create a check box called locked out on the table and hide it from the form layout,. Then in your Ui action you only set this check box to true. Now create a UI policy or client script to set the fields readonly and button when the checkbox value is true


coolsaurabh
Tera Contributor

Hi Abhinay,



I got your concept except check box. What do you mean by check box. Could you please give me an example.



Thanks


coolsaurabh
Tera Contributor

How to set check box true inside UI action