Make variables read only on catalog tasks once request approved

DClayton
Kilo Contributor

Hi,

I have a catalog item that has a number of variables- once submitted these variables are made read-only on the RITM. I'm assuming there is a business rule of ACL that enforces this, as the same applies for other catalog items.

The workflow for my catalog item has a number of sequential tasks and I can add the variables into each task using the list collector in the workflow editor.

When I am testing the RITM, I find at the task level the variables can be edited. This is OK as the fulfillment group for each task may want to add/edit the values in these variables as the workflow progresses.

There is an approval stage in the workflow that, once approved, I would like the subsequent tasks after this to have the variables made read-only. I only want it to apply to this catalog item, so am attempting this via catalog UI policy.

I did read this great post by the SN Guru, but couldn't find a way to make the script check if the request had been approved.

Any suggestions appreciated.

Thanks!

3 REPLIES 3

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to write catalog client script to make variable read only for your catalog item.

I hope that you are updating RITM stage after worklow approval activity.

You can use this RITM stage in catalog client script to make variable read only.

 

Please see sample script below

 

function onLoad() {

 

 

 

var request = g_form.getReference('request', getRequestDetails);

 

 

 

function getRequestDetails(request){

 

          if(request.approval == 'approved'){

 

                g_form.setReadOnly('variables.<databaseVariableName>', true); // give name of database variable here

 

          }

 

}

 

}

 

 

Regards,

Sachin

Also, it's better to use GlideAjax instead of getReference() since getReference() won't work in Service portal.

 

Regards,

Sachin

DClayton
Kilo Contributor

Thanks, I tried the following script but found it made my variables read-only on all tasks, regardless of approval?

function onLoad() {
var request = g_form.getReference('request', getRequestDetails);
	function getRequestDetails(request){
          if(request.approval == 'approved'){
                g_form.setVariablesReadOnly(true);
          }
}
}

There is an approval action in the workflow that marks the request approved.