The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Mark Roethof
Tera Patron
Tera Patron

Hi there,

Working with the out-of-the-box Checklist formatter? A nice feature. Though did you also encounter that when the record is closed (active=false) or a user does not have write access to that record, the Checklist items actually are still editable (not read-only)? There's an easy fix for this.

Checklist formatter

As mentioned, the Checklist formatter is out-of-the-box available. You could for example add the Checklist formatter to the Incident form.

find_real_file.png

find_real_file.png


Closed record, Checklist items still editable

All looks well and functions nicely. Though when displaying a closed record (active=false) or a record on which the logged-in user doesn't have write access to, still the Checklist items are editable (not read-only).


Updating out-of-the-box components

The Checklist (and with this the Checklist items) is shown when the Checklist formatter is available on a form. Looking at the Checklist formatter, this actually references a UI Macro: inline_checklist_macro.

find_real_file.png

Looking at the code of UI Macro inline_checklist_macro, on line 30 we would need to influence the read-only property. Out-of-the-box, this is hardcoded set to false. Ideally, we would influence this property so it is dynamically true or false. For example depending on the active flag or write access.

Within g2:evaluate, we could define a property dynamically and use this for the read-only property. For example:

var readonlyBool = false;
if(!current.canWrite()) {
	readonlyBool = true;
}

readonlyBool would now represent if the logged-in user has write access on the current record. Within g:macro_invoke we could use this readonlyBool on the read-only property by changing the read-only property to readonly="$[readonlyBool]".

You might also want to consider not using !current.canWrite, though current.active == false instead or a combination. That's completely up to you.

Full code UI Macro 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();
		}
		
		var readonlyBool = false;
		if(!current.canWrite()) {
			readonlyBool = true;
		}
	</g2:evaluate>
	<body>
		<j2:if test="$[!isNewRecord]">
			<g:macro_invoke macro="checklist_template" readonly="$[readonlyBool]" record="$[sysID]" 
							table="$[tableName]" checklistid="$[checklistID]"/>
		</j2:if>
	</body>
</j:jelly>

 

Result

When opening an Incident with a user that doesn't have write access on that Incident (Incident is closed, User has itil role), the Checklist items are now read-only.

find_real_file.png


Share

An Update Set with this updated UI Macro can be downloaded from Share:
- Checklist items still editable while record is closed [Fix]

---


And that's it actually. Hope you like it. If any questions or remarks, let me know!

đź‘Ť
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share projects on General / Platform I published?
General / Platform


Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn

Comments
ty_roach
Mega Guru

There are actually a number of "problems" with the out of the box checklist.  This is why we built Checklist Pro and why it's rated in the top 10 in the ServiceNow store.  I encourage everyone to watch this short video demonstrating some basic differences between the OOB checklists vs TyGR's Checklist Pro:

https://www.youtube.com/watch?v=paYmJujEjWM

A quick comparison:

Question Checklist Pro OOB Checklists
Assignable to any record in ServiceNow? Yes No
Supports Required vs Optional checklist items? Yes No
Supports multiple data types? Yes No
Supports hierarchical checklists? Yes No

Supports shared checklists?

(i.e. same checklist appear on multiple records)

Yes No

Configurable controls?

(i.e. which checklist to apply to a record and who may or may not edit the checklist)

Yes No
     
Mark Roethof
Tera Patron
Tera Patron

This article is also not about promoting a paid Share app. It's only intended to share some information about a problem I encountered multiple times on the checklists, the checklist items still being editable.

You could also discuss if what you are mentioning are problems/issues. In my opinion: there's not.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

Version history
Last update:
‎08-31-2020 04:29 AM
Updated by: