Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Script not working for the edit variables in RITM

Community Alums
Not applicable

Hi,

I wrote a small script to see that a logged in user should be able to edit the fields in the RITM provided the logged in user is from SHAREPOINT SUPPORT group but, it's not working. I impersonated as one of the users of that group, but the fields remain not editable. Kindly help.

 

onLoad Client Script

 

microsoft.PNG

 

 

function onLoad() {

	if (g_scratchpad.isMember != 'true') {
		g_form.setReadOnly('team_name', true);
        g_form.setReadOnly('business_group', true);
		g_form.setReadOnly('content_owner', true);
        g_form.setReadOnly('team_purpose', true);
    }

}

 

 

Business Rule

 

business_rule_1.PNG

 

business_rule_2.PNG

 

 

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

    if (gs.getUser.isMember("SHAREPOINT SUPPORT"))
    {
        g_scratchpad.isMember = 'true';
    }
})(current, previous);

 

Regards

Suman P.

 

 

 

6 REPLIES 6

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Change the Display BR as below

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

    if (gs.getUser.isMemberOf("SHAREPOINT SUPPORT")) //function is isMemberOf , you had isMember
    {
        g_scratchpad.isMember = 'true';
    }
})(current, previous);

 

-Anurag

Naga Ravindra R
Kilo Sage

hi @Community Alums 

 

change below:

 

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

    if (gs.getUser.isMemberOf("SHAREPOINT SUPPORT"))  //use ismemberof
    {
        g_scratchpad.isMember = 'true';
    }
})(current, previous);

SunilKumar_P
Giga Sage

Hi @Community Alums, Can you try gs.getUser().isMemberOf as shown in the below script?

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

    if (gs.getUser().isMemberOf("SHAREPOINT SUPPORT"))
    {
        g_scratchpad.isMember = 'true';
    }

})(current, previous);

 

Regards,
Sunil

Community Alums
Not applicable

Hi @Anurag Tripathi @SunilKumar_P @Naga Ravindra R ,

Thank you so much, but it didn't work. So, I updated the business rule and removed onLoad Client Script completely. This is not working either. I am doubting if the Business Rule is running at all. I don't get any alert. Kindly help.

 

business_rule_1.PNG

 

business_rule_2.PNG

 

 

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

    if (gs.getUser.isMemberOf("SHAREPOINT SUPPORT"))
    {
		alert("i am in the sharepoint support group");
        g_form.setReadOnly('team_name', false);
        g_form.setReadOnly('business_group', false);
		g_form.setReadOnly('content_owner', false);
        g_form.setReadOnly('team_purpose', false);
    }
	else{
		alert("i am not in the sharepoint support group");
		g_form.setReadOnly('team_name', true);
        g_form.setReadOnly('business_group', true);
		g_form.setReadOnly('content_owner', true);
        g_form.setReadOnly('team_purpose', true);
	}
})(current, previous);

 

 

Regards

Suman P.