2 Replies Latest reply: Jan 30, 2015 11:59 AM by Eric Park RSS

    Try to get OSUser() into Extension Object

    Some Nath Roy

      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[i];

                                  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.