How to make a variable read only on a record producer after closing the incident

sath
Tera Expert

Hi,

 

We need to make a variable on a record producer read only. It will be editable after incident is submitted, but should be read only for incident is closed. Please assist.

1 ACCEPTED SOLUTION

When the form is saved, it reloads, so you also need a similar onLoad Client Script.

View solution in original post

8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

You could use a Client Script like this on the incident table:

function onLoad() {
	if (g_form.getValue('state') == 7) { //Closed
		g_form.setReadOnly('var_name', true); //your variable name
	}
}

Hi @Brad Bowman  

 

The above script is not working. The variable that needs to be read only is part of record producer and it will be displayed under variables tab in an incident.

I have that mocked up in my PDI and the script works for me. Is the value of the State field on the incident you are looking at 7 for Closed or do you have something else in your instance?  The script I suggested is onLoad, so it won't happen when the State value changes before the form is saved.  Use an onChange script in addition if you want that to happen.

Hi @Brad Bowman  

Here's the script I have used:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (g_form.getValue('state') == 6) { //Resolved
        g_form.setReadOnly('variables.type', true);
    }
}

We need to make the field read only if state is resolved. When the state is set to resolved, it's being set to read only, but becomes editable once i save the form. I believe something else is interfering with this field, but this is the newly created field