Controlling Form State

For any forms in the Hire to Retire package, there are prebuilt rules pass the current Validation Node name as a query string parameter in the URL.  This will take the form of node=ValidationNodeName.  As an example of usage, the stock Form I-9 only shows the Employer section of the form when the onboarding package is in a Validation Node name Waiting HR.  Some GlobalForms administrators might be more familiar with controlling form state based on the Javascript submission.metadata variable outlined rules documentation found here.  While this variable may be applicable if you have a GlobalCapture workflow defined to pick up the individual resource forms directly, the Hire to Retire package is based on the capture processing of the HR Onboarding landing page form.  Hire to Retire is configured to pass the corresponding Validation Node to all of the forms in the package automatically.

To access the query string parameters, add a Text Component to your form.  On the Data tab, add a Calculated Value rule that stores the node value from the query string.  Accessing query string parameters is documented here.  Depending on the use case, it is possible to implement both methods of accessing the current Validation Node.  The script below will set a Text Component's value to the node parameter passed in the query string, if one is available.  If no node value is found, it will attempt to use the submission value directly.  Lastly, it will set the value to an empty string.


var params = new URLSearchParams(window.location.hash.split('?')[1]);
if(params.get('node'))
{
    value = params.get('node');
}
else if(submission && submission.metadata)
{
    value = submission.metadata.Node;
}
else
    value = '';