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.

Make checklist items read only once task is closed

gowthamanbalu
Tera Contributor

Hello All,

I would like to know if there is a way to restrict checklist items in the record form being updated or modified after record moved to closure state.

find_real_file.png

Regards,

GB

1 ACCEPTED SOLUTION

francescodotti
Mega Expert

Hi,


after trying with ACL and Client scripts, I found a very simple way.


You have to modify the UI Macro inline_checklist_macro. I added a condition linked to the state of the containing task



inline_checklist_macro


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g2:evaluate>


var isBrowserSupported = (GlideVTBCompatibility.getCompatibility() != 'block');


var isNewUI = gs.getProperty('glide.ui.doctype', 'false') == 'true';


var isNewRecord = true;


if (isBrowserSupported $[AMP]$[AMP] isNewUI) {


var sysID = current.getUniqueValue();


var tableName = current.getTableName();


isNewRecord = current.isNewRecord();



// get the checklist ID for this record


var checklistID = null;


var checklist = new GlideRecord("checklist");


checklist.addQuery("document", sysID);


checklist.addQuery("table", tableName);


checklist.query();


if (checklist.next())


checklistID = checklist.getUniqueValue();


if (current.state == -5 || current.state == 3 ) { // Pending or Closed


var readOnly = "true";


} else {


var readOnly = "false";


}


}


</g2:evaluate>


<body>


<j2:if test="$[!isNewRecord]">


<g:macro_invoke macro="checklist_template" readonly="$[readOnly]" record="$[sysID]"


table="$[tableName]" checklistid="$[checklistID]"/>


</j2:if>


</body>


</j:jelly>





Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.


View solution in original post

6 REPLIES 6

nishailame
ServiceNow Employee
ServiceNow Employee

Create new UI policy with condition active = false or state = closed. and mark this field read only.




 


Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.


nishailame
ServiceNow Employee
ServiceNow Employee

For example -



Screen Shot 2017-08-28 at 3.44.16 PM.png



Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.


gowthamanbalu
Tera Contributor

Thanks!



Here checklist is not a field. it is additional functionality which can be enabled through plugin. So, There is some UI pages and UI macro inorder to get them displayed on the ticket form layout.



Regards,


GB


https://community.servicenow.com/message/689424#689424



 


Thanks.


PS: Hit like, Helpful, Correct, if it answers your question.