How to make one variable editable on the RITM while all others read only

Brett Vaughn
Tera Contributor

I am developing a catalog and need to have one of the variables remain editable after the approvals are received.  It only needs to be editable until the first task is completed.  Right now, I am just trying to override setting the read only property after setting all the other variables to read only.  The way I have it below is not functioning correctly.   Any assistance would be greatly appreciated. 

function onLoad() {
   var stage = g_form.getValue('sc_req_item.stage');
   if(stage == 'request_approved' || stage == 'completed'){
        setTimeout(function () {
            g_form.setVariablesReadOnly(true);
        }, 500);
      }
   //Revert legal hold to editable
   g_form.setReadOnly('legal_hold', false);
   g_form.setDisplay('legal_hold',true);
}
1 ACCEPTED SOLUTION

Out of curiosity, if you edit the code to look like below, does it execute the way you'd like it to?

 

function onLoad() {
   var stage = g_form.getValue('sc_req_item.stage');
   if(stage == 'request_approved' || stage == 'completed'){
        setTimeout(function () {
            g_form.setVariablesReadOnly(true);
            
            g_form.setReadOnly('legal_hold', false);    //Revert legal hold to editable
            g_form.setDisplay('legal_hold',true);
        }, 500);
      }

}

 

 



If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!

View solution in original post

9 REPLIES 9

Jon Hogland
Tera Guru

What is the current behavior of the script when executed in the instance? Can you share a screenshot of the form before and after? My initial guess is that there is some other rule executing that we're unaware of, but seeing the form will help dig further. 



If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!

If the stage is not request_approved or completed, the form will set all of the variables on the SCTask to read only.  I have tried to create another client catalog script that will set the read only property of the legal_hold field to false if the task short description is "Verify if employee is on legal hold", but that hasn't worked either.  

Can you order the client scripts?  That field isn't exposed, but I can see it available.  I haven't tried setting that for the scripts. 

BrettVaughn_0-1739235290403.png

 

Out of curiosity, if you edit the code to look like below, does it execute the way you'd like it to?

 

function onLoad() {
   var stage = g_form.getValue('sc_req_item.stage');
   if(stage == 'request_approved' || stage == 'completed'){
        setTimeout(function () {
            g_form.setVariablesReadOnly(true);
            
            g_form.setReadOnly('legal_hold', false);    //Revert legal hold to editable
            g_form.setDisplay('legal_hold',true);
        }, 500);
      }

}

 

 



If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!

Well, that works on the RITM.  Once the RITM stage is Request Approved, it shows the legal_hold field, and it is editable. But the legal_hold field doesn't show on the SCTask.  That was where I was hoping to have the user interact with the field, but I may have to leave it like this and direct them to update the RITM.

 

I have checked UI Policies, Business Rules, Client Scripts and can't figure out how to override the read only properties in the SCTask.  I thought I had found a UI Policy causing the conflict, but I disabled it and still have the issue. 

BrettVaughn_0-1739245023728.png

BrettVaughn_1-1739245310624.pngBrettVaughn_2-1739245367598.png