How to show a Form Field when member belongs to a specific Group?

tech_tc
Mega Contributor

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



1 ACCEPTED SOLUTION

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


      }





}  


View solution in original post

16 REPLIES 16

In fact, from my POV, the best and most reliable is an ACL field/read.



With UI scripts (Client Scripts) you're hidding it from the form, but not from the lists, from the reports, or from any other higher level automation, like webservices, appart from security constraints, like javascript tweaks.



If you want security, use security and don't rely on the client side... By the way, trust in Roles, they are cheap!


Security is probably not the driver in this particular case. We have a portal page with a form and we only want relevant fields to appear.


The way we have this setup is that general users do not need any roles to access the portal, which the boss is pleased about!


Don't know how much the roles cost myself.


In any case, thanks for your point on security as i was not aware of this.