Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

How to get the name of the current user

Hi all

I have a script in the Edit Module as such:

public Function CurrentUser()
      Set objNetwork = CreateObject("Wscript.Network")
      CurrentUser = objNetwork.UserName
      msgbox currentuser
end Function

It works fine when opening the .qvw but when opening from Access Point the following error is returned:

Capture.JPG

(The "Schedules" in the image above is a name of a sub which calls the  CurrentUser() function.)

Does anyone know how to correct or is there another way of getting the name of the current user?

Any insight will help.

Thanks

Josh

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Macro's often don't work on the server. Try using the OSUser() or QVUser() qlikview function.


talk is cheap, supply exceeds demand
jduenyas
Specialist
Specialist
Author

Thanks Gysbert.
However, with that said  I also have a function in the Edit module to which I can pass a name of filed and a value (or an array of values). The function will then select the passed values to the filed (such as in a list box)
Here is the function:
public function SelectInListBox(byval strFieldName, byval strArrayListOfNames)
      dim i,j
      i = lbound(strArrayListOfNames)
      j = ubound(strArrayListOfNames)

      set f = ActiveDocument.Fields(strFieldName)
      set fv = f.GetSelectedValues

      if fv.count > 0 then
           fv.RemoveAt 0
           f.SelectValues fv
      end if
      set fv = f.GetNoValues       'empty array
    
      for i = 0 to j
           fv.Add
           fv(i).Text = strArrayListOfNames(i)
           fv(i).IsNumeric = false
      next
      f.SelectValues fv
End Function
Is it possible to pass the value of OSuser() or a valiable to a macro?
Thanks
(PS is there a comprehnsive list of all the VB methods and properties that can be used in the Edit module? Un fortunately it is not a full fledged VB editor and has its own functions/methods/properties. I am aware of the APIguide.qvw but it is lacking much information)