Make few variables editable on sctask

Advaitk
Tera Contributor

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 

7 REPLIES 7

pr8172510
Tera Guru

Hey @Advaitk,

Create ACL 

Field Value
Typerecord
Operationwrite
Namesc_item_variables_task
Conditiongs.getUser().isMemberOf('Your Assignment Group Name')

No role needed. The condition handles it.



 Use Your Existing Script with Small Fix

Display Business Rule (on sc_task):

 
g_scratchpad.canEdit = gs.getUser().isMemberOf('Your Assignment Group Name');

onLoad Client Script (System UI > Client Scripts - NOT Catalog Client Script):

 
function onLoad() {
    if (g_scratchpad.canEdit) {
        g_form.setReadOnly('variables.your_variable_name', false);
        g_form.setReadOnly('variables.another_variable', false);
    }
}

 

Hi Thanks for the response.

Tried your solution but still not working.

Tanushree Maiti
Mega Patron

Hi @Advaitk , 

 

You can an onLoad Catalog Client Script that applies to Catalog Tasks.

function onLoad() {
       if (g_user.hasRole('admin')) {              
g_form.setReadOnly(
'variables.your_variable_name', false); //Make the variable editable } else { // Make it read-only for non-admins
g_form.setReadOnly(
'variables.your_variable_name', true); } }
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

It is already editable for admin. We want for other users also.

I am facing this issue for this catalog item only. For others same type of BR and client script working fine.

Thanks for the response!