if incident task state is one of closed complete, closed incomplete, closed skipped then form should be in read only and ative= false

yogesh jori
Tera Contributor

 if incident task state is one of closed complete, closed incomplete, closed skipped then form should be in read only and ative= false

1 ACCEPTED SOLUTION

Hajar BENJAHHAR
Mega Sage

Hello, 

Your goal is to set actuve to false and at the same time to disable all fields in the form. 

Propostion to achieve this is to create a display business rule and a client script. 

    1- Display business rule : 

find_real_file.png

find_real_file.png

find_real_file.png

 

    2- client script : 

find_real_file.png

function onLoad() {
// put the desired states : 
    if (g_scratchpad.active=="false" && (g_scratchpad.state =="6" || g_scratchpad.state == "7" || g_scratchpad.state == "8")) {
        //Set all fields read only
        for (var x = 0; x < g_form.elements.length; x++) {

            g_form.setReadOnly(g_form.elements[x].fieldName, true);
        }
    }

}

Regards, 

Hajar

View solution in original post

5 REPLIES 5

Abhijit4
Mega Sage

Hi Yogesh,

You can create "write table.*" ACL and in condition section mention the conditions for which you would want it to be editable. This ACL will make all fields read if condition will not satisfy.

Let me know if you have any further queries.

Please mark this as Correct or helpful if it helps.

Thanks and Regards,
Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

I want form read only and active filed false for those state condition. can you please provide one solution for both.

sai krishna10
Giga Guru

Hi Yogesh

You can use the below as example.

 

Write the below script in onload client script or in ui policy script condition then it will make all the fields read-only.

var state = g_form.getValue('state');
if(state == 4 || state == 3)// Closed complete or closed incomplete
{
var grt_fields = g_form.getEditableFields();  
	//Set all fields read only
		for (var x = 0; x < grt_fields.length; x++) {  
			
			g_form.setReadOnly(grt_fields[x], true);  
		} 
}

 

Mark as correct/helpful if this solves this issue.

shloke04
Kilo Patron

Hi,

Please follow the steps below to achieve your requirement:

1) When you make incident Task as Closed, Active =false happens automatically and is an OOB behavior.

2) To make it Read Only, create a Read Operation Table Level ACL on Incident Task table and implement it as below:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke