
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 06:14 AM
Hi,
I have a scenario, on the sc_task form, a variable should be editable, if the logged in user belongs to certain group. I have written some part of the code. Kindly help.
Client Script
function onLoad() {
if (g_scratchpad.isMember == true)
{
g_form.
}
}
Business Rule
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf('TFS-ALABAMA') || gs.getUser().isMemberOf('TFS-BIRMINGHAM (RC)') || gs.getUser().isMemberOf('TFS-MID WEST'))
{
g_scratchpad.isMember = true;
}
})(current, previous);
This is the variable to be remained editable for the following groups.
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 07:03 AM - edited 12-20-2023 07:10 AM
The scratchpad variable is used in conjunction with onLoad Client Scripts when the Business Rule is triggered on display of the record, so change When to run:
Also, the value needs to be a string to get passed to the client, and it's a good idea to always set a value to prevent any errors on the client, so change your BR script:
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf('TFS-ALABAMA') || gs.getUser().isMemberOf('TFS-BIRMINGHAM (RC)') || gs.getUser().isMemberOf('TFS-MID WEST')) {
g_scratchpad.isMember = 'true';
} else {
g_scratchpad.isMember = 'false';
})(current, previous);
Then your Catalog Client Script would look like this:
function onLoad() {
if (g_scratchpad.isMember == 'false') {
g_form.setReadOnly('variable_name', true);
}
}
of course replacing variable_name with the name of your variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 07:38 AM
Hello @Community Alums ,
Step 1: Create a display Business rule with script as below on sc_task table.
(function executeRule(current, previous /*null when async*/) {
if (gs.getUser().isMemberOf('grp1 name') || gs.getUser().isMemberOf('grp2 name') )
{
g_scratchpad.isMember = true;
}
})(current, previous);
Now create a Onload catalog client script to hide the variable.
function onLoad() {
var test = g_scratchpad.isMember;
if(test ==true){
g_form.setReadOnly('variable_name',true);
}
}
Kindly mark my answer as Correct and helpful based on the Impact.
Regards,
Siddhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 12:34 PM
Hello @Community Alums ,
Haven't you seen my solution? As I given the exact same answer way before...If this help you please mark as helpful