Qlik Community

QlikView Extensions

Discussion Board for collaboration on QlikView Extensions.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
somenathroy
Contributor III

Try to get OSUser() into Extension Object

Dear All,

My objective is to use the logged in user name into a QV Extension. For that I have declared a variable through Variable Overview dialogue as  : vLoggedinUser =OSUser()

Have checked that the value of the variable showing correctly in a standard QV text object as <domainname>\<username>.

Now want to take this value in an extension object, so have written the following code block in Script.js file :

/*setting VariABLES*/

var _this = this;

var vUser ;

  _this.StaticPros = {};

  _this.StaticPros .UserName = eval('_this.Layout.Text0.text');

  var qvDoc = Qv.GetCurrentDocument();

                qvDoc.GetAllVariables(function (vars) {

                    if (vars != null) {

                        for (var i = 0; i < vars.length; i++) {

                            var obj = vars;

                            if ((obj.isreserved == "false") && (obj.isconfig == "false")) {

                                if (obj.name.toLowerCase() == _this.StaticPros .UserName.toLowerCase()) {

                                    vUser = obj.value.toString();  //return variable definition text

                                                                               //[i.e =OSUser() , should return <domainname>\<username>]

                                  //vUser = obj.name.toString();   //return the name of the variable [i.e vLoggedinUser ] correctly

                                }

                            }

                        }

                    }

                });

vUser = obj.name.toString();  returns the name of the variable [i.e vLoggedinUser ] which is perfect.

But, vUser = obj.value.toString(); returns variable definition text [i.e =OSUser() ] which is wrong. It should return <domainname>\<username>].

Can anyone point me if I am missing anything or any better idea ? Would appreciate your help.

Regards,

Som

2 Replies
somenathroy
Contributor III

Re: Try to get OSUser() into Extension Object

Dear All,

Has anyone faced this problem ?

Regards,

som

Partner
Partner

Re: Try to get OSUser() into Extension Object

in Definition.xml add:

<Text Label="OSUSER" Type="text" Initial="" Expression="=OSUser()"/>

then in the javascript reference it by:

_this.Layout.Text0.text