Scripting

<< Click to Display Table of Contents >>

Navigation:  Windows > User Interface >

Scripting

 

Questions and answers about OMNITRACKER Windows User Interface ↦ Scripting:

 

How to enable/disable controls in a form?

This behavior depends on whether the control is linked to an action or a field or not:

  • If the control is linked to an OMNITRACKER field, it cannot be locked/unlocked by script lines before input, since the control over the permissions of the respective user is done by the system. In this case, the permissions defined for the respective user in the folder definition apply.
  • If the control is NOT linked to an OMNITRACKER field, the "Enabled" flag in the control properties in the form editor must be set. The code lines: <ctrl>.Enabled = False and <ctrl>.Enabled = True can then be used as expected.

In case of an edit control, also the "Locked" property can be used. Further information can be found in the OMNITRACKER Form Editor Help.

 

How can a "Download ALL" button be implemented on a Windows form?

Below, please find the code to achieve the download of all attachments (Onclick code) on a "download all icon":

If Not ActiveRequest.Fields("Attachments").IsNull Then
myStartFolder = ""
Set objAllAttachments = ActiveRequest.Fields("Attachments").TValue
Set WshShell = CreateObject("WScript.Shell")

myStartFolder = WshShell.ExpandEnvironmentStrings("TEMP")
SelectFolder = vbNull

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.BrowseForFolder(0, "Select Folder", 0, myStartFolder)
If IsObject(objFolder) Then SelectFolder = objFolder.Self.Path

strPath = CStr(objFolder.Self.Path)

Set objFolder = Nothing
Set objShell = Nothing

If myStartFolder <> "" Then
For Each objAllAttachment In objAllAttachments
strAttachmentName = objAllAttachment.Name
strFileStore = strPath & "\" & strAttachmentName
objAllAttachment.WriteToFile(strFileStore)
Next
MsgBox "All Attachments are stored on the following location: " & strPath, vbInformation
End If

Else
MsgBox "There are no Attachments present to save", vbCritical
End If