How to make multi-row variable set read-only on RITM and Catalog Tasks?

dianemiro
Kilo Sage

Any chance someone here already made the multi-row variable set to read-only on RITM and Catalog Tasks?

Thanks,
Diane

1 ACCEPTED SOLUTION

Hi Diane,

 

Could you please use g_form.setVariablesReadOnly(true);  and let me know if this works?

 

Please mark the answer as correct if it suffice your query.

 

Thanks.
Soumita.

View solution in original post

13 REPLIES 13

Harsh Vardhan
Giga Patron

just confirming here , do you want to disable the edit icon ? or you want to make variable read only. ?

 

if you will write catalog ui policy on your multi-row variable set and make those variables read only through catalog ui policy then user can able to click on "edit" icon but those variable would be read only. 

 

make sure you checked the "Applies on Requested Items" check box. 

Hello Harshvardhan,

I was looking for a way to disabled add, edit, remove all and remove buttons. I have created a UI policy for all the variables inside the variable set but this only applies to variables when I click on edit button. Any other suggestions? I appreciate your response.

Diane

 

the only way i can see is DOM manipulation, but that's not a good approach.

 

Sample Code:

 

function onLoad() {
	//Type appropriate comment here, and begin script below

var x = document.getElementById("f810755bdb266300e4d95740cf9619d0Add"); //Add button id
  x.style.visibility ="hidden";
 

}

 

let's wait for other folks they might give you some other solution here. 

 

Soumita3
Tera Expert

Hi Diane,

 

You could use and modify the code as per your requirement.

Below is an on load client script written on Requested Item table, the same can be written on TASK table. Both worked for my case.

 

function onLoad() {


var _status = g_form.getValue('state');


// Should we disable or enable?
if (( _isAssignee || _isSupporter) && (_status == 1 || _status == 2)) {
// Let fields enabled
} else {
// disable fields
disableVariables();
}
}

/************************************************************************************************
Disable all variables on form

Approach used here comes from "Service Now Guru"
http://www.servicenowguru.com/scripting/business-rules-scripting/variables-form-readonly/

Problems: A field can be disabled and made readonly. We only made it read only.
Making it disabled will have the result that the values of these fields
are not going to be POSTed anymore. Resulting in empty fields after an update.
Negativ is that fields still look like editable but aren't.

*************************************************************************************************/

function disableVariables() {


g_form.setVariablesReadOnly(true);

//REQUESTBAU-92 changes -- setReadonly all the variables present on TASK form after the request is closed
var taskState = g_form.getValue('state');
if(taskState == 3 || taskState == 4 || taskState == 7){
for(var i=0; i<g_scratchpad.taskVar_pool.length; i++){
g_form.setReadOnly(g_scratchpad.taskVar_pool[i],true);
}
}
// Remove any reference or calendar icons
ve.select('img[src*=reference_list.gifx]', 'img[src*=small_calendar.gifx]').each(function(img) {
img.hide();
});

// Hide list collector icons
ve.select('img[src*=arrow]').each(function(img) {
img.up('table').hide();
});




}

 

Please mark the answer as correct if it suffice your query.

 

Thanks.
Soumita.