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

Hi Dave, On the display BR you cannot use g_form and its functions so you need to use both as shown below.

 

Your BR should be 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);

 

 

 

 

 

Along with this you have to use the client script

 

 

 

 

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);
    }
else
{
		
		g_form.setReadOnly('team_name', false);
        g_form.setReadOnly('business_group', false);
		g_form.setReadOnly('content_owner', false);
        g_form.setReadOnly('team_purpose', false);

}

}

 

 

 

 

If this doesn't work then Can you tell us how are you testing this?

 

-Anurag

Anirudh Pathak
Mega Sage

Hi @Community Alums ,

You are missing "()" after "getUser".

Please use the below codes - 

Business Rule:

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

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

 

Client Script -

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);
    }

}