Skip to content

Commit e7aa2f9

Browse files
authored
Restrict fields on template (#2659)
* Add script to display user mentions in Service Portal This script retrieves and displays the top 5 records where the logged-in user is mentioned, providing links to those records. * Delete Modern Development/Service Portal Widgets/My Mentioned Items directory * Create script.js * Delete Modern Development/Service Portal Widgets/My Mentioned Items directory * Create script.js * Delete Server-Side Components/Scheduled Jobs/Retire Rating 1 Articles directory * Create script.js * Update script.js * Create README.md * Update README.md * Update script.js
1 parent c786bc5 commit e7aa2f9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**Details**
2+
3+
This is a on change client script on sys_template table. This script will restrict users to select defined fields while template creation.
4+
Type: OnChange
5+
Field: Template
6+
Table: sys_template
7+
8+
**Use Case**
9+
10+
There is an OOB functionality to restrict fields using "**save as template**" ACL, but it has below limitations:
11+
1. If the requirement is to restrcit more number of fields (example: 20), 20 ACLs will have to be created.
12+
2. The ACls will have instance wide effect, this script will just restrict on client side.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Type: onChnage
3+
Table: sys_template
4+
Field: Template
5+
*/
6+
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
7+
if (isLoading || newValue === '') {
8+
return;
9+
}
10+
if (g_form.getValue('table') == 'incident') { // table on which sys_template is being created.
11+
var fields = ['active', 'comments']; // array of fields to be restricted while template creation.
12+
for (var i = 0; i < fields.length; i++) {
13+
if (newValue.indexOf(fields[i]) > -1) {
14+
alert("You Cannot Add " + fields[i]); // alert if user selects the restricted field.
15+
var qry = newValue.split(fields[i]);
16+
g_form.setValue('template', qry[0] + 'EQ'); // set the template value to previous values (oldValue does not work in this case).
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)