- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
For a catalog item, when the request is submitted the RITM is created and the approval is triggered for two approvers, At this approval stage the RITM variables should be editable for the two approvers in the RITM for that particular Item.
I have tried using the catalog client script but it's not working
Catalog client script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
my below response should help you with the script.
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
3 hours ago
Hi @Tamilvanan T ,
On which table you are creating this client script?
Is the RITM variables read-only for all users?
Verify if write roles field is restricting editing of these.
It is not a best practice to use hard coded sys_id's.
If you want users to modify variables it is always a good option to create a task, add variables to the task and make them editable
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I'm using the catalog client script for that particular catalog item i want the variables should be editable for the approvals.
Yes, the RITM variables are read-only for all users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
my below response should help you with the script.
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
3 hours ago
you should use normal onLoad client script on RITM and not catalog client script
Also use Display business rule to get the approvers for that RITM
Business Rule:
Condition: Item [IS] Your Item Name
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var arr = [];
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", current.sys_id);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('approver'));
}
g_scratchpad.approvers = arr.toString();
})(current, previous);
Client Script:
function onLoad() {
var loggedInUser = g_user.userID;
var arr = g_scratchpad.approvers.toString().split(',');
if (arr.indexOf(loggedInUser) > -1 && g_form.getValue('approval') == 'requested') {
g_form.setVariablesReadOnly(false);
} else {
g_form.setVariablesReadOnly(true);
}
}
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