Page 1 of 1

Access Level

Posted: Mon Mar 29, 2021 11:23 am
by GlenMcCabe
I have an access level called admin. There are 3 users with this access level. I now need to block 1 user from 1 tabs on a particular form. The form has 3 tabs

Main File maintenance Reports

I need to block the user from the reports tab.

Thanks

Re: Access Level

Posted: Mon Mar 29, 2021 11:30 am
by kev1n
Hi,

Add this in your form's Custom Code:

Code: Select all

if (nuUserName() == 'replace_with_user_name') {
    nuHideTabByTitle('Reports');
}

Re: Access Level

Posted: Mon Mar 29, 2021 2:58 pm
by GlenMcCabe
Thanks Kevin

Is this available in 4.5 only. I am still running 4

I get an error when I add this to before Edit

Re: Access Level

Posted: Mon Mar 29, 2021 3:11 pm
by kev1n
What error do you get?

if the function nuHideTabByTitle(s) is not available in v4, you can "borrow" it from v4.5.:

https://github.com/nuBuilder/nuBuilder- ... m.js#L2390

Re: Access Level

Posted: Mon Mar 29, 2021 3:57 pm
by GlenMcCabe
This is the error

Before Edit of Form FF17

/home1/ccchubda/public_html/ccchubdev/nucommon.php(1255) : eval()'d code
Call to undefined function nuUserName()

Traced from...

(line:42) /home1/ccchubda/public_html/ccchubdev/nuapi.php - nuBeforeEdit

(line:67) /home1/ccchubda/public_html/ccchubdev/nuform.php - nuEval

(line:1255) /home1/ccchubda/public_html/ccchubdev/nucommon.php - eval


an you explain how to borrow the function

Re: Access Level

Posted: Mon Mar 29, 2021 4:21 pm
by kev1n
It looks like the code is not in the form's Custom code. Just place nuHideTabByTitle() under Setup -> Header or also in the form's Custom Code field.

Code: Select all

function nuHideTabByTitle(s) {

	var tabs = JSON.parse(JSON.stringify(nuSERVERRESPONSE)).tabs;
	var l = tabs.findIndex(data => data.title === s);
	if (l > -1) nuHide('nuTab' + l);

}

if (nuUserName() == 'replace_with_user_name') {
    nuHideTabByTitle('Reports');
}

Image

Re: Access Level

Posted: Mon Mar 29, 2021 4:54 pm
by GlenMcCabe
Thanks kevin

I have done that and dont get an error. Unfortunately the user is on leave so will not be able to check until thursday.

Re: Access Level

Posted: Mon Mar 29, 2021 5:17 pm
by kev1n
You could test it with any other (test) user.

Re: Access Level

Posted: Mon Mar 29, 2021 8:57 pm
by GlenMcCabe
Kevin

working. Thanks

Re: Access Level

Posted: Wed Mar 31, 2021 6:36 pm
by apmuthu
Backported these functions into my v4 updated repo.