Scripting

<< Click to Display Table of Contents >>

Navigation:  Windows > Core System >

Scripting

 

Questions and answers about OMNITRACKER Core System ↦ Scripting:

 

How to script a Print-Button that shall print the opened request on a default printer?

The OnClick script for the print button should perform the following three steps:

  1. Create the .DOC- or .PDF-file in the local file system of the client:

    Set WshShell = CreateObject("WScript.Shell")
    TempFileName = WshShell.ExpandEnvironmentStrings("%Temp%") & "\TempOtReport.doc"

    Set fs = CreateObject("Scripting.FileSystemObject")
    If fs.FileExists(TempFileName) Then fs.DeleteFile TempFileName, True

    Set objFld = ActiveSession.RequestFolders("MyFolder")
    Set objTask = objFld.Tasks("MyTask")
    Set objReqs = objFld.CreateRequestList
    objReqs.AddExisting ActiveRequest
    ErrStr = objTask.Execute (objReqs, TempFileName, 2) '1=Pdf, 2=Word
  2.  
    • 2a. Start printing on the default printer (.DOC file):

      If ErrStr = "" Then
      Set msWord = CreateObject("Word.Application")
      msWord.Documents.Open(TempFileName)
      msWord.Application.PrintOut
      msWord.Quit
      set msWord = Nothing
      Else
      MsgBox "Error: " & ErrStr
      End If
    • 2b. Start printing on the default printer (.PDF file):

      strCommand = """%ProgramFiles%\Adobe\Reader 10.0\Reader\AcroRd32.exe"" /t " & TempFileName
      WshShell.Run strCommand, 0, True
  3. 3. Delete the temporary file:

    If fs.FileExists(TempFileName) Then fs.DeleteFile TempFileName, True

 

How to handle errors when executing an external VBScript on a 64bit-system?

Error ActiveX component cannot create object (OtAut.Application)

When starting a VBS-file on a 64-bit system, it is executed in the 64-bit subsystem by default. If the 32-bit OtAut.dll is being used to do this, error messages will be displayed.

To execute the script in the 32-bit subsystem, please start it the following way:

C:\WINDOWS\SysWOW64\wscript.exe "MyScript.vbs"

 

How to use an unattached RequestList control?

  1. Please include the following line in the OnOpen script of the form:

    myControl.object.Session = ActiveSession
  2. Please activate the following OnChange script in the tab control. An Update is only necessary if the page "MeinTabname" is displayed:

    If TabControl.CurrentPage.Name = "MeinTabname" Then
    Set objFolder = ActiveSession.RequestFolders("<FolderName>")
    Set objFilt = objFolder.MakeFilter
    Set objFilt.UserField("<Feld-ImRef-Folder>") = ActiveRequest
    myControl.object.Clear
    myControl.object.Filter = objFilt
    myControl.object.UpdateAllRequests
    End If