Form ID Special Use Cases
Beginning in the 3.76.00 release, a form's ID is no longer generated and assigned as soon as the user opens a form in the ADD task. Instead the form ID value is set to "NEW" until the first save occurs. At that point, a form ID is claimed and assigned to the form.
This change affects at least two somewhat common form use cases, but there may be others:
- Storing the form ID in a form field
- Scenarios in which the form ID needs to be assigned prior to save processing
This document aims to help users build new forms and retrofit existing forms in which one of these use cases applies.
This document applies only to forms that both:
- Use helium performance, and
- Are initiated by end users
Form ID behavior has not changed for standard forms or code-initiated forms (programmatic creation). These use cases still generate and assign form IDs at creation time and, as such, no special handling is required.
Storing the Form ID Value In a Form Field
If your form has one or more configured fields that are used to store the form ID value, historically, you could set these fields to initialize from the GT-delivered Form ID SmartSource. This no longer works because the Form ID SmartSource now returns "NEW" when the form is first created.
Instead of Initialize, these fields should now employ the Form ID SmartSource in the Update When This Source Changes configuration. Doing so will allow the GT Framework to automatically detect when the form's ID has been assigned and update the fields appropriately.
Form ID Assignment Prior to Save Processing
There are many scenarios in which form logic may require that form ID be assigned prior to save processing, most of which include saving data related to the form before the form itself has been fully saved.
To address this scenario, GT recommends two options:
- First, consider the possibility of moving the logic that relies on form ID to occur after the first save has occurred. If this is possible, the best option would be to place to logic in the
SavePostChangePeopleCode hook. See the API Documentation for additional information. - If placing the logic to after the first save is not possible, GT delivers a form object method called
ClaimAndSetFormIDthat can be called just before the form ID is needed. This method generates and assigns a form ID for the form if one has not already been assigned. This method can be used like so:
Component G3FORM:Form &G3FRM;
method DoSomethingWithFormID
&G3FRM.ClaimAndSetFormID();
Local string &formId = &G3FRM.FormID;
end-method;