Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Personalized Hash Variables
-
- Posts: 49
- Joined: Thu May 03, 2018 12:08 pm
Personalized Hash Variables
Hi,
Is there a way to create new Hash variables to store common information for my app and use it in the sql statements?
I would like my app could manage multi companies and this could help me.
Thanks in advance.
Is there a way to create new Hash variables to store common information for my app and use it in the sql statements?
I would like my app could manage multi companies and this could help me.
Thanks in advance.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Personalized Hash Variables
Hi,
There's a function nuSetProperty(). The property can then be used as a Hash Cookie.
https://wiki.nubuilder.cloud/ ... etProperty
Can you provide more details on what you're trying to accomplish?
There's a function nuSetProperty(). The property can then be used as a Hash Cookie.
https://wiki.nubuilder.cloud/ ... etProperty
Can you provide more details on what you're trying to accomplish?
-
- Posts: 49
- Joined: Thu May 03, 2018 12:08 pm
Re: Personalized Hash Variables
Hi toms,
All the tables have a field called company_id and there is another table associating user_id with company_id in such a way that I would like that the users could only see the records of their company.
I tried to insert PHP code in BE section of Launch to run sql statements and get the company_id for the logged user and store it in a $GLOBALS var, but it doesn't work and when I try to access to these $GLOBALS from BB in the Form the data doesn't exists.
Thank you.
All the tables have a field called company_id and there is another table associating user_id with company_id in such a way that I would like that the users could only see the records of their company.
I tried to insert PHP code in BE section of Launch to run sql statements and get the company_id for the logged user and store it in a $GLOBALS var, but it doesn't work and when I try to access to these $GLOBALS from BB in the Form the data doesn't exists.
Thank you.
Re: Personalized Hash Variables
ahernandez,
There are some preset Hash Cookies you can use in a Form's Browse Tab SQL.
https://wiki.nubuilder.cloud/ ... sh_Cookies
Your SQL in could be something like...
Steven
There are some preset Hash Cookies you can use in a Form's Browse Tab SQL.
https://wiki.nubuilder.cloud/ ... sh_Cookies
Your SQL in could be something like...
Code: Select all
SELECT * FROM clients WHERE salesperson_id = '#USER_ID#'
Steven
You do not have the required permissions to view the files attached to this post.
-
- Posts: 49
- Joined: Thu May 03, 2018 12:08 pm
Re: Personalized Hash Variables
Hi,
I know those Hash Cookies. The question is if I could create my own Hash Cookies.
I think it would be the soluction, otherwise what other ways are to do something similar?
Thank you.
I know those Hash Cookies. The question is if I could create my own Hash Cookies.
I think it would be the soluction, otherwise what other ways are to do something similar?
Thank you.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Personalized Hash Variables
Yes with nuSetProperty() - see my first reply.ahernandez wrote:Hi,
I know those Hash Cookies. The question is if I could create my own Hash Cookies.
I think it would be the soluction, otherwise what other ways are to do something similar?
Thank you.
But a query, something like this, should do the job:
Code: Select all
SELECT table.* FROM table
INNER JOIN company
ON table.company_id = company.company_id
WHERE company.user_id = '#USER_ID#'
-
- Posts: 49
- Joined: Thu May 03, 2018 12:08 pm
Re: Personalized Hash Variables
Hi toms,
I think it won't work...
I will try to explain. I don't speak a good English. Sorry.
I need to get the g_company_id value from a table accessing with #USER_ID# in BE PHP section before Launch Form using SQL like you said.
This is the code in that section..
$g_user_id = nuHash()['USER_ID'];
$s = "SELECT * FROM employee WHERE epl_user_id = '" . $g_user_id . "'";
$t = nuRunQuery($s);
$r = db_fetch_row($t);
$g_company_id = $r[1];
I would like to store this g_company_id value in a hash coockie for to be used in the SQL Statements for browse every form launched from this Launch Form.
By the moment I have solved this including a SELECT inside WHERE CLAUSE but I don't like pretty much...
SELECT
customer.*
company.*
FROM customer
LEFT JOIN company ON com_company_id = company_id
WHERE com_compnay_id = (SELECT epl_compnay_id FROM employee WHERE epl_user_id = '#USER_ID#')
I would like something like this...
WHERE com_compnay_id = '#g_company_id#'
Thank you toms and admin for listening and answer...
I think it won't work...
I will try to explain. I don't speak a good English. Sorry.
I need to get the g_company_id value from a table accessing with #USER_ID# in BE PHP section before Launch Form using SQL like you said.
This is the code in that section..
$g_user_id = nuHash()['USER_ID'];
$s = "SELECT * FROM employee WHERE epl_user_id = '" . $g_user_id . "'";
$t = nuRunQuery($s);
$r = db_fetch_row($t);
$g_company_id = $r[1];
I would like to store this g_company_id value in a hash coockie for to be used in the SQL Statements for browse every form launched from this Launch Form.
By the moment I have solved this including a SELECT inside WHERE CLAUSE but I don't like pretty much...
SELECT
customer.*
company.*
FROM customer
LEFT JOIN company ON com_company_id = company_id
WHERE com_compnay_id = (SELECT epl_compnay_id FROM employee WHERE epl_user_id = '#USER_ID#')
I would like something like this...
WHERE com_compnay_id = '#g_company_id#'
Thank you toms and admin for listening and answer...
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Personalized Hash Variables
To my knowledge there is no function to add a (global) Hash Cookie that is valid in all forms.
I asked for the same in another topic but no solution was offered.
I asked for the same in another topic but no solution was offered.
-
- Posts: 49
- Joined: Thu May 03, 2018 12:08 pm