Page 1 of 1

Session hash variables

Posted: Mon Sep 23, 2019 4:00 pm
by mariri
Hi guys !

I want to add a new session hash variable like the hash cookie "USER_ID" which is always available.
I know how to declare the variable (file : nuformclass.js, function : addBreadcrumb() in the class "nuFormObject") but I don't know where can I set the property of this variable ? In which file ?

Do u have any idea ????

Thanks in advance !

Re: Session hash variables

Posted: Mon Sep 23, 2019 4:43 pm
by kev1n
Hi,

Does this variable contain a static value or is it retrieved from a DB table?

Re: Session hash variables

Posted: Mon Sep 23, 2019 4:57 pm
by mariri
A static value like the login and the password entered when you log in !

Thanks !

Re: Session hash variables

Posted: Mon Sep 23, 2019 6:42 pm
by kev1n
You can use nuSetProperty() to set a hash cookie - e.g. under setup -> header
https://wiki.nubuilder.cloud/ ... etProperty

Re: Session hash variables

Posted: Tue Sep 24, 2019 2:22 pm
by mariri
Thanks for ur anwser. I tried ur solution but it doesn't work
I don't know if I'm doing things correctly :(

To be more precise, I added a select (named 'nuservice') in the file nuconfig.php :

<div id='outer' style='width:100%'>
<div id='login' class='nuLogin'>
<table>
<tr>
<td align='center' style='text-align:center;height:50px' colspan='2'>
<div id='nulogo' style='margin:50px 0px 20px 65px;background-size:100% 100%;background-image:url(\"graphics/logo.png\");width:200px;height:80px;'></div>
</td>
</tr>
<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Login</span></td>
<td style='text-align:left'><input id='nuusername'/></td>
</tr>
<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Mot de passe</span></td>
<td style='text-align:left'><input id='nupassword' type='password' onkeypress='nuSubmit(event)'/></td>
</tr>

<tr>
<td style='text-align:right;margin:0px 5px 0px 20px;'><span style='padding:0px 5px 0px 40px;'>Service</span></td>
<td style='text-align:left'>
<select id='nuservice' style='width:172px;'>
<option value='1'>OCCITANIE 09</option>
<option value='2'>OCCITANIE 31</option>
<option value='3'>OCCITANIE 34</option>
<option value='4'>OCCITANIE 46</option>
<option value='5'>OCCITANIE 82</option>
<option value='6'>PRIR 03</option>
<option value='7'>PRIR 63</option>
<option value='8'>PRIR 45</option>
</select>
</td>

</tr>
<tr>
<td style='text-align:center' colspan='2'>
<input id='submit' type='button' class='nuButton' style='margin:20px 0px 0px 50px;width:90px;height:30px;' onclick='nuLoginRequest()' value='Log in'/>
</td>
</tr>
</table>
</div>
</div>


I added this code in the file nuformclass.js (a hash variable named 'service' appears in the list of the hash variables) :

addBreadcrumb(){

var b = {};
b.form_id = '';
b.redirect_form_id = '';
b.record_id = '';
b.title = '';
b.call_type = '';
b.column_widths = 0;
b.filter = '';
b.forms = [];
b.iframe = 0;
b.lookup_id = '';
b.object_id = '1';
b.page_number = 0;
b.password = '';
b.rows = -1;
b.row_height = 25;
b.search = '';
b.session_id = '';
b.nosearch_columns = [];
b.sort = '-1';
b.sort_direction = 'desc';
b.subforms = 0;
b.tab_start = [];
b.username = '';
b.user_id = '';

b.service = '';

this.breadcrumbs.push(b);

return this.getCurrent();
}

I tried ur solution by adding this code under setup -> header but it doesn't work :

function nuHeaderTest() {
console.log('Functions placed here before a closing script tag are available anywhere in nuBuilder Forte');
}

nuSetProperty('service', 'nuservice');

</script>
<style>

</style>
<script>



Like the hash cookie "USER_ID", I'd like to use the option value selected for 'service' at any time on Nubuilder.
Sorry I'm new on Nubuilder and I don't know too much about :(

Re: Session hash variables

Posted: Tue Sep 24, 2019 3:39 pm
by mariri
Ok I got it !!!

I add a code in the function nuGetUserAccess() in the nucommon.php file and it works perfectly

Thanks for ur help kev1n !!! :P