Make few variables editable on sctask
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi everyone,
I have created a Catalog Item that successfully generates a Request Item (RITM) and a Catalog Task (SCTASK) upon submission.
The requirement is to make specific variables editable on the SCTASK form, whereas they should remain read-only by default. To achieve this, I implemented a combination of a Display Business Rule (to pass data via g_scratchpad) and an onLoad Client Script to toggle the field permissions.
This solution works perfectly for System Administrators (the variables are editable). However, when I impersonate a standard user from the assignment group assigned to that task, all the variables remain strictly read-only.
Has anyone encountered this issue before, or can you point me toward what might be blocking this?
Thanks!
CC: @Ankur Bawiskar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hey @Advaitk
For SCTASK variable editing, you need both:
Write ACL access
Client-side logic to remove read-only state
Solution
Create Write ACL
Table:
sc_item_variables_task
Operation:
write
Script:
answer = current.task.assignment_group &&
gs.getUser().isMemberOf(current.task.assignment_group);This allows users from the task assignment group to update variables.
Display Business Rule on sc_task
(function executeRule(current, previous) {
g_scratchpad.canEdit =
gs.getUser().isMemberOf(current.assignment_group);
})(current, previous);onLoad Client Script
function onLoad() {
if (g_scratchpad.canEdit || g_user.hasRole('admin')) {
g_form.setReadOnly('variables.variable_name_1', false);
g_form.setReadOnly('variables.variable_name_2', false);
}
}
Important Notes
Admin works because ACLs are bypassed automatically.
Without the sc_item_variables_task write ACL, non-admin users will always see variables as read-only.
Also verify that:
Variable itself is not marked Read Only
No Catalog UI Policy is forcing read-only
No other Client Script is resetting the field state
One additional improvement:
In some cases, variable fields on SCTASK behave inconsistently with individual setReadOnly() calls. You can also try:
g_form.setVariablesReadOnly(false);and then selectively make required variables read-only again if needed.
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
27m ago
Thanks for the response. I tried your solution but it is not working. Don't know why.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Please use a catalog client script to specify where your UI policy should be applied. For reference, please follow the diagram provided below.(use read only false)
this won't work fallow this one
