Script not working for the edit variables in RITM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 06:02 AM - edited 02-27-2024 06:03 AM
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
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
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser.isMember("SHAREPOINT SUPPORT"))
{
g_scratchpad.isMember = 'true';
}
})(current, previous);
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 06:56 AM - edited 02-27-2024 07:57 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 07:24 AM
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);
}
}