Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

In RITM When State is Closed Completed after 1 day it should be readOnly

nameisnani
Mega Sage

Hi,

 

1 .We have a requirement that in RITM form when state is selected as closed complete , after 1 day it should become Read only.

 

2. as similar we have request that when state is closed incomplete , closed skipped , then state field should be read only immediately . This one we achieved through UI Policy.     

 

i Need help in Point 1 .

 

Please help me on this .

 

@Saurav11 @kamlesh kjmar 

3 ACCEPTED SOLUTIONS

On your RITM form, press CTRL + SHIFT + J and execute below code, and share what's the alert msg you are getting

 

alert(g_scratchpad.closedDaysAgo)

 

kamleshkjmar_0-1669097501692.png

 

View solution in original post

@nameisnani 

 

What was the issue with the UI policy I has suggested earlier:-

 

In the UI policy change the script to below  and then try to test  it should work:-

 

function onCondition() {
  var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
    g_form.setReadOnly(fields[x], true);
}
}

 

Saurav11_0-1669103714759.png

 

Please mark my answer as correct based on Impact.

View solution in original post

@nameisnani 

 

Remove closed complete option from selection in your OR condition of UI policy, as highlighted in below screen shot

 

kamleshkjmar_0-1669192172291.png

 

 

I hope this helps.


Regards,

Kamlesh

View solution in original post

24 REPLIES 24

@Ankur Bawiskar 

 

Could you please provide me the steps to achieve this requriment

 

Hello @nameisnani 

 

Maybe you can shift to UI policy:-

 

Please try the below:-

 

UI policy condition:-

 

Saurav11_0-1669090262956.png

 

Then in the run this script part use the below code:-

 

Saurav11_1-1669090319427.png

 

Please mark my answer as correct based on Impact.

 

@Saurav11 

 

When we select state is Closed Incomplete , Closed skipped --- it should be readonly immediately

@nameisnani 

 

Yes that is why if you see I have added the bigger OR for that condition:-

 

Saurav11_0-1669090788502.png

 

Please mark my answer as correct based on Impact.

 

@Saurav11 

 

while selecting table i am able to see like this there is no sc_req...

SunilKumarPadh_0-1669091177742.png