- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015 06:02 AM
How to show a Form Field when member belongs to a specific Group? - in Eureka
I'm using Eureka now and would like to only reveal 2 special fields on a form to users that are in a specific group.
e.g. Users belonging to a 'BackupOperatorGrp' group have 2 mandatory fields on a form to fill in. example field names are 'Backup Type' and 'Backup Start Time' . The backup operators will enter random text as a string in the fields. Anyone else not in the 'BackupOperatorGrp' group will not even see these fields when the form launches.
I gather that a UI policy maybe the way to go with but i can't select 'group' from the Conditions: drop-down and can't see it in the Show Related Fields either. Therefore i'm assuming i need to put a script in-place. I've laid out the UI Policy as below. Any help help creating this script would be appreciated.
UI Plicy for Showing Fields for Backup Operators Only - (example only)
Table: B_Operators_Update
Short Desc: Show Fields To Backup Operators Only
Global: ticked
Reverse if False: ticked
On load: ticked
Inherit: unticked
Run scripts: ticked
Execute if true: script
Solved! Go to Solution.
- Labels:
-
Integrations
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015 05:49 AM
try this one. The section of code with answer is probably misleading you.
It needs to be calculated and you are not doing so
this code should work on just the users group membership
It will add an info message at the top of the page and then make fields visible / non visible
function onLoad() {
//if(g_user.isMemberOf('BackupOperatorGrp'))
//return;
g_form.addInfoMessage('Scratchpad : ' + g_scratchpad.isMember);
//if(g_user.isMemberOf('BackupOperatorGrp') && answer < -60 )
if (g_scratchpad.isMember == true)
{
g_form.setVisible('u_backup_type',true);
g_form.setValue('u_backup_type','');
g_form.setMandatory('u_backup_type',true);
g_form.setVisible('u_backup_start_time',true);
g_form.setValue('u_backup_start_time','');
g_form.setMandatory('u_backup_start_time',true);
}
else
{
g_form.setVisible('u_backup_type',false);
g_form.setMandatory('u_backup_type',false);
g_form.setVisible('u_backup_start_time',false);
g_form.setMandatory('u_backup_start_time',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015 07:03 AM
happens to us too. It is very brief.
What would be nice would be when you create a form to be able to add a field, but have it set initially to visible = false and then use a UI policy or script to make it visible
Even having a ui policy to initially hide it does not make a difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015 08:20 AM
Many Thanks Julian
I really appreciate you help.
Lets hope the SN Developers have a tweak at this sometime in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 11:35 PM
Hi @poyntzj
I used the above client script and modified it to show 3 custom fields i created for category, sub category and effort in hours but it is hiding the fields for all users. I want these fields to be available for group TAM Cat and Sub Cat.
Below is the code i am using and i am getting error in form 'Scratchpad : undefined'.
function onLoad() {
//if(g_user.isMemberOf('TAM Cat and Sub Cat'))
//return;
g_form.addInfoMessage('Scratchpad : ' + g_scratchpad.isMember);
//if(g_user.isMemberOf('TAM Cat and Sub Cat') && answer < -60 )
if (g_scratchpad.isMember == true)
{
g_form.setVisible('u_tam_category',true);
g_form.setValue('u_tam_category','');
g_form.setMandatory('u_tam_category',true);
g_form.setVisible('u_tam_sub_category',true);
g_form.setValue('u_tam_sub_category','');
g_form.setMandatory('u_tam_sub_category',true);
g_form.setVisible('u_effort_in_hours',true);
g_form.setValue('u_effort_in_hours','');
g_form.setMandatory('u_effort_in_hours',true);
}
else
{
g_form.setVisible('u_tam_category',false);
g_form.setMandatory('u_tam_category',false);
g_form.setVisible('u_tam_sub_category',false);
g_form.setMandatory('u_tam_sub_category',false);
g_form.setVisible('u_effort_in_hours',false);
g_form.setMandatory('u_effort_in_hours',false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015 06:20 AM
there are two ways to do this.. one as mentioned above is to use a client script and query the database to check group membership...a different way would be to pass in the groups in a scratchpad variable in an on display br.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015 07:58 AM
Doug, I understand it would be best to do this with a client script, but i'm happy to accept any examples as my scripting level is not great.