hexagon logo

Dynamic Variable on Report

Hello. I'm looking to get some insight into this request and see if it is even possible.

The basic idea of what I want to try and do is add two variables to my report. These variables would be the location of the report and the user who is logged in to the computer.

So, when we save reports, everything is sorted by part number and then lot number. (example: \part123\lot456\date.pdf) If that is the save location defend in the report window print setup, is there anyway to get the "lot456" input as a variable in the header, only by defining the path in the report print setup? See example picture for reference.

The second thing I would like to do is add the have the currently logged in windows user show on the report. Ideally the display name but if only the username is possible, that is fine too.

Any help would be much appreciated. Thanks!

Parents
  • Good day,

    this variant uses a modified label and vba script, so it can be used in any program without variables

    1.) make a backup copy of "FILE_HEADER.LBL"
    2.) edit this file in pcDMIS: "File->Reporting->Edit->Label Template->"FILE_HEADER.LBL" (a custom label is also possible here)
    3.) "Label Template Editor" should open
    4.) add a simple text-field anywhere in "Label Template Editor"
    5.) right-click anywhere in "Label Template Editor" -> Settings opens
    6.) left-click your text-field you added earlier
    7.) left-click right to "event handler" within "Properties" see image -> "VBS Mini-Editor" should open
    8.) in this VBS Mini-Editor you can add a simple vbs script wich will fire every time the report is generated

    example for username:
        Dim ObjWshNw As Object
        Set ObjWshNw = CreateObject("WScript.Network")
        
        'MsgBox ObjWshNw.UserName
        'MsgBox ObjWshNw.ComputerName
        'MsgBox ObjWshNw.UserDomain
    
        this.text = ObjWshNw.UserName
    


    "this.Text = " is the content of the text field as string (works only within "VBS Mini-Editor")

    pcDMIS variables can also be read out and displayed in the text field.
    if you need an example for this let me know​


Reply
  • Good day,

    this variant uses a modified label and vba script, so it can be used in any program without variables

    1.) make a backup copy of "FILE_HEADER.LBL"
    2.) edit this file in pcDMIS: "File->Reporting->Edit->Label Template->"FILE_HEADER.LBL" (a custom label is also possible here)
    3.) "Label Template Editor" should open
    4.) add a simple text-field anywhere in "Label Template Editor"
    5.) right-click anywhere in "Label Template Editor" -> Settings opens
    6.) left-click your text-field you added earlier
    7.) left-click right to "event handler" within "Properties" see image -> "VBS Mini-Editor" should open
    8.) in this VBS Mini-Editor you can add a simple vbs script wich will fire every time the report is generated

    example for username:
        Dim ObjWshNw As Object
        Set ObjWshNw = CreateObject("WScript.Network")
        
        'MsgBox ObjWshNw.UserName
        'MsgBox ObjWshNw.ComputerName
        'MsgBox ObjWshNw.UserDomain
    
        this.text = ObjWshNw.UserName
    


    "this.Text = " is the content of the text field as string (works only within "VBS Mini-Editor")

    pcDMIS variables can also be read out and displayed in the text field.
    if you need an example for this let me know​


Children
No Data