Page 1 of 1

Can we access to user level from javascript client event?

Posted: Tue Mar 29, 2022 6:04 pm
by amiens80

hi,

in my event client side, i need to add a specific behavior depending of the user level.

is there a javascript variable which already store the user level value ? a variable i could use in the client Startup script ?

in the exemple and the documentation, you put a value of 2 for Manager.
in javascript, how can i get access to that value ?

Best regards


Re: can we access to user level from javascript client event ?

Posted: Tue Mar 29, 2022 6:28 pm
by mobhar

You may simply use SetClientVar() global function to set a client variable from server-side.

Search in this forum for SetClientVar for more info and examples. See also the documentation of Some Global Functions


Re: Can we access to user level from javascript client event?

Posted: Thu Mar 31, 2022 3:47 pm
by amiens80

thank you a lot.

so, i my server event function Page_Rendering() , i added :

$user_level = CurrentUserLevel();
SetClientVar("My_JS_Var", $user_level);

and client side, in my loadjs.ready("load", function() (startup script) , i can access to it with :

alert(ew.vars.My_JS_Var);

Solved !
have a good day.


Re: Can we access to user level from javascript client event?

Posted: Tue Dec 06, 2022 9:29 pm
by vintoICT

great!