Hello, what is the proper way pass the current user key to a Query?
I looked at these both threads Expression in SQL query - #2 by shweta and Live Query Not Working - #7 by Abu_Bakr_Siddique but they are not any help.
Here is my query
SELECT
iUser
.iUserKey
,
iUser
.UserID
,
iUser
.FullName
,
iUser
.iUserRecordKey
FROM
iUser
WHERE iUserKey = ?
Here is my parameter
I tried {{five.current.UserKey()}} and {{five.stack.iUser.iUserKey}} with no success.
with and without brackets. The user’s role has permission to read iUser table.
In Five Inspector , the string is still empty.
What am I doing wrong? Thanks,
Jean
Hi @JeanXXIV,
You can use five.currentUserKey() to get it.
Refer to the document for more details:
currentUserKey() | Five | Low-Code For Real Developers
No sorry, does not work 
The query works when I replace the ‘?’ by the iUserKey in the query itself…
SELECT
iUser
.
iUserKey
,
iUser
.
UserID
,
iUser
.
FullName
,
iUser
.
iUserRecordKey
FROM
iUser
WHERE
iUser
.
iUserKey
= “f2ce88dd-29e1-4da0-99e6-88246ff8040c”
If {{five.currentUserKey()}}
is not working as expected, you can set as a variable and use {{five.variable.UserKey}}
in the parameters
Sample function to set variable which can be assigned to the Application’s Do Logon event or any other relevant event
function ApplicationDoLogon(five, context, result) {
five.setVariable("UserKey", five.currentUserKey());
return five.success(result);
}
Ok yes! Now it works, thanks for your quick reply.