Join the Team Forms community

Updated last month

Dynamic Permissions

At a glance

The community member who posted the original post would like to have permissions based on usernames selected from a User Component that a user inputs, rather than having permissions pre-determined by the form builder. In the comments, another community member suggests two methods to achieve this: conditionally showing/hiding components based on the selection in a user component using JavaScript, or using custom logic to dynamically enable/disable components based on the selection of a user component. The community member provides an example of the first method, where a panel component is only visible if the logged-in user's email matches the selected user's email.

It would be great to have permissions based on usernames from selected from a User Component that a user inputs. Right now permissions is pre-determined to whoever has been set by the form builder as per below.



E
1 comment

Hi Adrian,

This should already be possible to achieve either using one of the following methods:

  1. Conditionally showing/hiding components based on the selection in a user component using javascript

  2. Using custom logic to dynamically enable/disable components based on the selection of a user component

For example using method one you could use the steps below to only allow the selected user to see and edit a specific section of your form:

  1. Drag and drop a user component into your form

  2. Drag and drop other components into your form which you want to make avialable conditionally. In this example let's use a panel component.

  3. Under the "conditional" tab of the panel component, add the following javascript to the "Advanced Conditional" property. This expression checks that the logged in user matches the selected user and makes the approval section visible if this is true.

    NOTE: you will need to adapt the expression below to fit your specific form and needs.

    JavaScript
    show = tf.user?.email === data.userComponentName.mail


Here is an example of the final output.