Page 1 of 1
Hide individual form fields for users? Possible??
Posted: Thu Mar 11, 2021 8:53 pm
by Olikun
Hi,
I have another question.
Sorry, my english is not good. I use the google translator
I have a form where my employees should enter data.
Can I hide individual form fields for some users?
The employees should not see all fields, only those in which they should enter something.
Many greetings
Re: Hide individual form fields for users? Possible??
Posted: Thu Mar 11, 2021 9:17 pm
by Janusz
Hi,
You can use nuAccessLevelCode() or nuUserName() in JS to identify the user and use nuHide() with field id:
for example:
use in Form JS custom code:
Code: Select all
if (nuFormType() == 'edit') {
var usr=getUser();
if (!(usr=="admin" || usr=="Janusz"))
{nuHide('adm_links3');nuHide('adm_links4');}
}
---- define in header ----
Code: Select all
function getUser() {
var user = nuUserName();
if (user === '') { user = "admin";}
return user;
}
Re: Hide individual form fields for users? Possible??
Posted: Fri Mar 12, 2021 7:59 am
by kev1n
Here's another code to hide certain fields if the Access Level code is "alcEmployee"
Add the code to your
form's custom code
Code: Select all
// Declare the fields/nuBuider Object IDs here, that you want to hide
var fieldsToHide =
['cus_created_date',
'cus_created_user',
'cus_updated_date',
'cus_updated_user'];
function hideFields(f, condition) {
for (var i = 0; i < f.length; i++) {
nuShow(f[i], ! condition); // (v4.5 specific)
}
}
if (nuFormType() == 'edit') {
hideFields(fieldsToHide, nuAccessLevelCode() == 'alcEmployee');
}
Re: Hide individual form fields for users? Possible??
Posted: Fri Mar 12, 2021 9:04 am
by Olikun
Hi,
Thank you, I think it's great how quickly you can get help here.
That's great.
I'll try it tonight
Re: Hide individual form fields for users? Possible??
Posted: Sun Mar 21, 2021 8:09 pm
by Olikun
works perfectly, thank you very much