Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

QVUser() value not refreshed

Hi ,

Im trying to load login user name to a table i.e qvuser() to a table.


Code -


Section Access;

LOAD * INLINE [

ACCESS, USERID, PASSWORD, REGION

ADMIN, ADMIN, ADMINPASS, *

USER, USER1, USER1, USA

USER, USER2, USER2, CANADA

USER, USER3, USER3, EUROPE

];

LET vVar=QVUser();

user_info:

LOAD * Inline [

USER NAME

$(vVar)];

The above code always returns me "ADMIN" rather than USER names. "ADMIN" in which the app was saved first time. Jus to cross check the function , I added a textbox with qvuser() and it is appearing properly.

Can any help me tel me why this behaviour

Tags (2)
4 Replies

Re: QVUser() value not refreshed

Probably because the only one who can perform a reload is ... ADMIN. Users with role=USER usually have the Reload-button disabled.

Peter

Not applicable

Re: QVUser() value not refreshed

After reload , the value gets updated. The scenario which Im trying is without reload the application . I want to join logged in user id to another internal user table.

Is there any way I can get USERID

Re: QVUser() value not refreshed

The difficulty you are facing is that during script execution all USERIDs are valid because a USERID is only significant when you open a document in the AccessPoint (or QV Desktop). At that moment, it's too late to start concatenating tables.

Maybe concatenating all USERIDs to your other table in section application anyway, and then using data reduction (which comes into action at Document-Open-time) to throw out all unwanted USERIDs may solve your case? You will have to perform a Cartesian product with all the Users that are already present in the second table, in order to avoid them getting wiped out by the data reduction. That could work just fine. But I don't know enough about your data model to provide you with a ready-to-use-example. [Edit] Check the attachment.

Does this untested example help?

SA_Source:

LOAD * INLINE [

ACCESS, USERID, PASSWORD, REGION

ADMIN, ADMIN, ADMINPASS, *

USER, USER1, USER1, USA

USER, USER2, USER2, CANADA

USER, USER3, USER3, EUROPE

];


Section Access;

SA:

LOAD * RESIDENT SA_Source;


Section Application;


SecondUserTable:

LOAD * INLINE [

USERID2

USER4

USER5

USER6

];


JOIN (SecondUserTable)

LOAD USERID RESIDENT SA_Source;


CONCATENATE (SecondUserTable)

LOAD USERID, USERID AS USERID2 RESIDENT SA_Source;


DROP Table SA_Source;


I became very curious about linking to USERID, so I tested it myself before posting. It seems to do the job...


Best,


Peter

Not applicable

Re: QVUser() value not refreshed

Thanks Peter , Im able to get the user ID with your script.

Community Browser