Skip to main content
InSource Solutions

TN - 1270 Automatically Detecting User Information on Form Load

Description

 

This article from InSource shows...

  • Author: Devin Hepburn  
  • Published: 06/23/2022
  • Applies to: AVEVA WorkTasks / Skelta BPM

Details

Forms will usually want to include information about the user accessing the form such as username and email.  Typing this in every time is tedious and leaves room for error.  This information can be accessed from the backend database and populated in the form XML at the time of load.  It can then be used to pass into database functions, workflows, or simply display on the form.

For this example, we will show to auto populate the username information into a text box at the time of form load.

1. Create form and text box control that will house the user information.  Take note of the control name or control ID.  For this example, the text control has ID "T5".

CreateField.png

 

2.  Click on properties at the top of the form to open the form properties pane.  From there, click on "Scripts" and you will see an area to edit the "On Form Load" script.

OnFormLoad.png

3.  Edit this to allow for user information to be obtained at the time of form load.

On Load Script.png

  • In this example, virtualActorId is used to store the actor ID, or the ID of the individual accessing the form.
  • virtualActorId is then passed into getUserLookupExtendedInformation to get information on that actor ID.  That dict of information is stored in the variable loggedOnUserInformtion.
  • From there, we can access information from the dictionary by passing the keys in a variable.key notation:
    • Username
    • UserDepartment
    • UserEmail
  • This example extracts the username and passes it into the T5 control.  This control is a text box that is not user modifiable.