allow a group to edit a variable in variable editor in ritm

Mouktik_B
Tera Contributor

I want to allow a group to edit a specific variable in ritm inside variable editor . 

the variable is set mandatory in the portal. 

How to achieve this?

 

3 REPLIES 3

Astik Thombare
Tera Sage

Hi @Mouktik_B ,

 

You can write display business rule to check whether the user is part of that particular group or not .for explanation .I'm considering a scenario like if currently logged in user is a part of CAB Approval group then only the user can edit variables otherwise it will be read only for other users .please refer below display business rule which is checking if the user is part of CAB approval group and it is passing that value to global object scratchpad 

 

 

 

(function executeRule(current, previous /*null when async*/ ) {

    g_scratchpad.checkUserGroup = gs.getUser().isMemberOf('CAB Approval'); // checking if user is part of CAB Approval Group
   
})(current, previous);

 

 

 

There is one OOB onload Clint script with name "Variable Editor Readonly" on sc_req_item table which is making these variables read only . I've edited this client script as per below which is making variables read only and editable based on scratchpad values 

 

OOB Client Script

AstikThombare4_1-1712387606181.png

Variables when user is part of CAB Approval Team

AstikThombare4_0-1712387545575.png

 

 

 

function onLoad() {
    if (g_scratchpad.checkUserGroup) {
        g_form.setReadOnly('please_provide_the_preferred_email_alias', false); // g_form.setReadOnly('variable_name', true);
        g_form.setReadOnly('business_justification', false);
    } else {
        g_form.setReadOnly('please_provide_the_preferred_email_alias', true);
        g_form.setReadOnly('business_justification', true);


    }
}

 

 

 

This way based on user's group we can make variables read-only or editable 

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

 

Thanks,

Astik

 

luffy3478
Tera Guru

why are you showing variables in portal ? 🙄

Community Alums
Not applicable

Hello @Mouktik_B 

"Please go through these articles."

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0778416

If you find my response helpful, mark as  "Helpful."