Hi guys,
@acjnas If the number of users who need to see the form is fixed and will always be three, you could use the code snippet in the post that @matthieu_chateau refered to and amend the condition like this :
if (
(document.querySelectorAll('div[data-mappedto="user_1"][data-value={LOGGED_IN_USER:EMAIL} i]').length > 0) ||
(document.querySelectorAll('div[data-mappedto="user_2"][data-value={LOGGED_IN_USER:EMAIL} i]').length > 0) ||
(document.querySelectorAll('div[data-mappedto="user_3"][data-value={LOGGED_IN_USER:EMAIL} i]').length > 0)
)
(I haven’t tested this exact syntax, it might require some light adaptation regarding the way you use {LOGGED_IN_USER:EMAIL}
as a dynamic value for your condition).
For a more generic solution that could handle more or less users, I would first create a new airtable field that would concatenate all emails and use the presence of the logged-in user’s email within that field as a condition :
if (document.querySelectorAll('div[data-mappedto="users_who_should_see_the_form"][data-value*={LOGGED_IN_USER:EMAIL} i]').length > 0)
where users_who_should_see_the_form
is the new field with all the emails.
Keep in mind that this would require that you first “display” on the page the values you use as conditions (user_1
, user_2
and user_3
in the first option, users_who_should_see_the_form
in the second option).
You can insert them and render them invisible with hidden
or collapse
.
You should check first that your fields render the needed value as a string for the email adress, if they’re lookups they might not and have their value send the user’s recordId instead. To do that, after you’ve inserted the fields on your page, you can use the Inspector within your browser and check if the data-value attribute on your fields is indeed an email (or several emails within a string in the second option).
Also keep in mind @dcoletta 's warning as this is in no way a secure solution to prevent unauthorized users to input data in your form.