- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2025 11:58 PM
Hi guys,
is there a way how to disable dot walking in a template?
Example:
If I create a template for incident table, I am able to use "Show related fields" option and set e.g. Configuration item.Owned by to some value.
This can end in two scenarios:
1. Such field is not on form and applying the template will show a warning that the field is not on the form, or
2. The dot-walked field is on the form and applying such template can unintentionally alter data in particular CI, not incident itself
Is there a system property or attribute to disable "Show related field" on a template?
The filed is type "template_value"
I found one community post in google that may be addressing this, but clicking on it shows it has been archived and redirects me to ITSM
https://www.servicenow.com/community/itsm-forum/disable-dot-walking-though-a-template/m-p/2427935
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 11:28 PM
Hi,
I got a response from ServiceNow support, it seems there is indeed no OOB settings to manage this.
So it's either BR or client script, we'll probably go with BR (I already mentioned this is the second thread).
BTW, your script is not entirely right, any template value can contain a dot (e.g. short description value) and your script would prevent submitting.
I am just gonna post it here in case someone is trying to get achieve the same:
(function executeRule(current, previous /*null when async*/ ) {
var dotWalkArr = [];
var conditionArr = [];
conditionArr = current.getValue('template').split('^');
for (var i = 0; i < conditionArr.length; i++) {
var field = conditionArr[i].split('=')[0];
if (field.includes('.')) {
dotWalkArr.push(field);
}
}
if (dotWalkArr.length != 0) {
gs.addErrorMessage('Following fields contain dot-walking reference which is not supported: ' + dotWalkArr.join(','));
current.template = previous.getValue('template');
current.setAbortAction(true);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 02:03 AM
not a good practice to set dot walked fields via template as the record belongs to other table
You should only configure fields from the table on which template is defined
I think you will have to deep dive to see if there is any attribute etc
Another way is to use before insert business rule and check the field value template_value has any field which is included as dot walked
If yes then abort the insertion and inform user to remove that
OR -> Working Approach below instead of deep diving
You can also use onSubmit client script on that "sys_template" table
something like this worked for me
function onSubmit() {
//Type appropriate comment here, and begin script below
var templateValue = g_form.getValue('template');
if (templateValue.indexOf('.') > -1) {
alert('Dot walked fields are not a good practice');
return false;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 11:28 PM
Hi,
I got a response from ServiceNow support, it seems there is indeed no OOB settings to manage this.
So it's either BR or client script, we'll probably go with BR (I already mentioned this is the second thread).
BTW, your script is not entirely right, any template value can contain a dot (e.g. short description value) and your script would prevent submitting.
I am just gonna post it here in case someone is trying to get achieve the same:
(function executeRule(current, previous /*null when async*/ ) {
var dotWalkArr = [];
var conditionArr = [];
conditionArr = current.getValue('template').split('^');
for (var i = 0; i < conditionArr.length; i++) {
var field = conditionArr[i].split('=')[0];
if (field.includes('.')) {
dotWalkArr.push(field);
}
}
if (dotWalkArr.length != 0) {
gs.addErrorMessage('Following fields contain dot-walking reference which is not supported: ' + dotWalkArr.join(','));
current.template = previous.getValue('template');
current.setAbortAction(true);
}
})(current, previous);