Hook for Form Timestamps

You can specify a timestamp for the form widgets without using the Date Time Selector widget by using the hook module GetFormTimeStampHook(FormStruct, Timestamp, PageObj)

By using this hook module, you can create a custom date picker or return a custom timestamp based on specialized time offset calculations. The current Form widget options for Time Offset and Time Unit are limited to predefined configurations. GetFormTimestampHook can add custom logic, including using Month and Year tags.

Parameter Details:

  • FormStruct has a TimeOffset field that the hook should use. It is the offset from the associated timestamp in seconds.

  • Timestamp - This will be the Timestamp on the Date Time Selector, if one is present.

  • PageObj - The form page.

Procedure

The module can reside either directly in the Page or in the AppRoot.

Create a module called "GetFormTimestampHook".

The module must take the three parameters: FormStruct, Timestamp, PageObj.

  • The hook module must be stable in steady state.

  • If FormStruct is Invalid, the hook module should return the relative timestamp.

  • The Timestamps returned by the hook module must be in UTC.

  • Clicking the submit button should not log an event in the following cases:

    • On a page with only a submit button.

    • On a page with a submit button and a form widget that is unlinked and not included in a form.

    • On a page with a submit button and a form widget that is unlinked and included in a form.

  • Clicking the submit button should log an event in the following cases:

    • On a page with a submit button and a form widget that is linked to a tag and included in a form.

    • On this page, if a Date Time Selector is added, then the Description column on the logged event should say "Form submitted " and mention the date and time, specified on the Date Time Selector.

    • If no Date Time Selector is present on the page, then the Description column would simply say "Form submitted".

    • The Name and Area columns in the logged event will correspond to the values entered in the Event Name and Event Area fields in the Submit button's config panel. If Event Name and Event Area are not provided, the Name will default to the page’s translated title, and the Area will be set to "Forms".

Examples:

<
{=========== GetFormTimestampHook ==========================}
{ Called when the submit button is clicked. This module will be called once   }
{ for every widget on the page that is included in the form. This module         }
{ should return a timestamp based on the properties of the FormEntry           }
{ structure.                                                                                                        }
{==========================================================}
GetFormTimestampHook
(
  FormEntry           { Structure of form data related to the widget            };
  Timestamp          { Timestamp drawn on the page                                };
  PageObj              { Object of page                                                        };
)

[
  PROTECTED FormMonth;
  PROTECTED FormYear;
  PROTECTED DateInDays;
  PROTECTED DateInSeconds;
  PROTECTED LocalOffset;
]

GetFormTimestamp [
  FormMonth = Scope(\VTSDB, "MonthOfForm").Value;
  FormYear  = Scope(\VTSDB, "YearOfForm" ).Value;

  If Watch(1, FormEntry, Timestamp, PageObj, FormYear, FormMonth);
  [
    LocalOffset   = PickValid(FormEntry.TimeOffset, 0);
    DateInDays    = DateNum(1, FormMonth, FormYear);
    DateInSeconds = (DateInDays * 86400) + LocalOffset; 
    Return(ConvertTimeStamp(DateInSeconds, 0 { Local time }, TRUE, Invalid { UTC }));

  ]
]

{ End of GetFormTimestampHook }
>