Custom Delay Windows for Triggers on the Youreka Form Object
This article provides a link to an extension pack that enables organizations to run any additional custom process after a Form has been submitted.
The extension pack can solve for many use cases, including but not limited to:
- Efficient and secure document generation using Advanced PDFs or 3rd party document generation tools
- Creating & updating related records
- Sending custom notifications
- Creating ContentDocumentLinks to relate Images and E-Signature files to related records of a Form
- Any downstream automated tasks related to Form Submission
This pack was developed to address the common need for organizations to implement custom automation following a Form submission. However, implementing custom automation after a Form submission often leads to challenges, such as missing required data, due to the way the Youreka Mobile Application synchronizes data with Salesforce.
By leveraging this extension pack to institute a delayed process, organizations can have far greater peace of mind when running automation after a Form has been submitted. This solution helps ensure all data submitted in a Form is consumable by custom processes, including image files.
This extension pack also supports a streamlined user experience that is not disturbed by synchronous processes running at the time of Form submission, meaning users can continue to work in the Youreka Mobile App without delays or interruptions.
Organizations can now set a time window (in minutes) for triggering automation to run on a 'Submitted' Form. We have also included a Lightning Web Component that can be added to custom Lightning Record Pages for the Youreka Form object to allow users to view if a Form record has been submitted and triggers have successfully fired.
What's included in the Extension Pack?
This is an unmanaged package, which we have released, and means the components of this package are editable to those users who have the ability to do so, such as System Administrators. We, however, do not recommend doing so unless you have consulted with the Youreka technical team first.
We may make periodic updates to the package. If this is done, this documentation will be updated accordingly, including any new explanations of functionality released/updated.
Metadata:
- Boolean field: Sync_Complete__c on the disco__Form__c Object
- Youreka Form Sync Complete Setting: Custom Metadata Type
- SyncStatusChange: Platform Event
- FSSControl: Permission Set
Apex:
- FormSync.Trigger
- FormSync_Delayed.cls
- FormSyncHelper.cls
- TriggerControl.cls
- SyncCompleteTest.cls
Lightning Web Component Bundle:
- formSyncStatus
Installing the Package
To install this package in a Production Environment:
- Click this Link
- Follow the installation instructions in the install screen
- Navigate to Setup > Apex Test Execution.
- Click Select Tests and choose the test classes included in the package: SyncCompleteTest
- Run the selected tests to validate the functionality of the package.
To install this package in a Sandbox Environment:
- Click this Link
- Follow the installation instructions in the install screen
- Optionally, validate the package by following step 3, 4 and 5 above
Add the LWC to your Form Lightning Record Pages
Once installed, you can add the LWC to Form record pages by doing the following:
- Navigate to a Form record in Salesforce (As a system administrator)
- Select the cog icon in the top right corner of your page
- Select Edit Page
- Create a new Record Page for the Form object and add the formSyncStatus LWC (located in the Custom Component section in the page editing interface) to the desired location on the page
- Save the configuration and assign page access accordingly
Give permission to users to run the Apex
Assign the FSSControl permission set to any Form users whose Form submissions may kick off additional database automation triggered by the Sync_Complete__c field on the Form object.
Explanation of Functionality
When a Form is Submitted for the first time
When a user submits a Form for the first time (i.e. that Form has never been submitted in the past) the FormSync Trigger processes the Form record and updates the Sync_Complete__c field on the Form record after a delay.
This process can be delayed by setting the 'Delay' field in the Youreka Form Sync Complete Setting to a whole number greater than 1. By default if no Sync Complete Setting is defined in the org, then the form will be processed and Sync_Complete__c set true after a 1 minute delay. The number you define dictates the time in minutes of the delay before the Form record update occurs.
The update is realized from a user perspective when the formSyncStatus LWC updates from 'Sync Status: Not Synced' to 'Sync Status: Synced':
If a Form is edited after It has been Submitted
The Form record instantly reverts to 'Sync Status: Not Synced' if the Form is not re-submitted. i.e. if the Form user uses the 'Save & Close' button in the Form in the Youreka Mobile App, the Form record moves to the 'In Progress' Status:
Both Processes act on the Sync_Complete__c field on the Form record. When 'Sync Status: Synced', Sync_Complete__c = True, when 'Sync Status: Not Synced' Sync_Complete__c = False.
The update to Sync_Complete__c is what is being delayed here and this update can be used to trigger further downstream automation.
Setting the delay window
As part of the package we have included a Custom Metadata Type called Youreka Form Sync Complete Setting. It is not necessary to create a record for this setting if you are happy with a 1 minute delay for the Form Sync Complete field update. However if you want to increase the delay, you can by adding ONE record to this custom metadata type and setting the delay to the number of minutes you want to delay this action for.
If you add more than one record here the code will pull the first record it finds. To minimize confusion over delay times only create one record of this metadata type.
Reasons for creating a larger delay might be that your org has many asynchronous processes running at any given time and to make more certain all data arrives in Salesforce efficiently from Youreka your delay to run other synchronous processes can be extended. Or if you have a large mobile workforce working offline syncing/saving many forms at one time periodically during their workday. An extended delay here lessens the burden on the database when additional automation is triggered to run after Form saves have completed.
To add a record for this metadata type:
- Head to Salesforce Settings
- Type Custom Metadata Types in the Quick Search bar
- Find the Youreka Form Sync Complete Setting
- Click, Manage Records
- Click, 'New'
- Enter a label for the record and set a value for the Delay field'
- Save.
Post Install Recommendations
For any new or existing automation you want to delay after a Form has been submitted, ensure that your automation is triggered or references the update of the Sync Complete field on the Form object.
Comments
0 comments
Please sign in to leave a comment.