In this article, you will see an example of Youreka implemented in a way that allows for the automated deletion of Forms, in certain situations.
Although it may seem counterproductive at first glance, there are many situations where it might make sense to automatically delete form records. Here are just a few examples:
- A user creates a form in the field, by mistake, and wishes to have that form discarded.
- Forms enter the Salesforce environment, and are no longer needed.
- Forms are incorrectly created or used, and a process must be setup to remove them.
What happens when we delete Form records?
When Form records are deleted from the system, the Form record itself is deleted, as well as all of its related Answer records. To be clear, deleting forms is a very different process than archiving forms. Before making decisions on how to deal with unnecessary forms, be sure to familiarize yourself with both of these separate processes.
Suppose an organization wanted to setup a process where forms are automatically deleted in certain situations. The organization might choose to setup the following Salesforce configurations to facilitate this:
- A custom checkbox field on the Youreka Form object (disco__Form__c) called Flag For Deletion.
- An After Insert record update flow, which looks to this checkbox and removes the Form record from mobile when the Flag For Deletion checkbox = TRUE.
- A scheduled flow (or batch apex) that identifies all of the forms in the org with Flag For Deletion = TRUE, and deletes the form records.
Obviously from the desktop UI, a user could have the ability to simply click the standard Delete button on a Form record directly. You could also setup a custom process that determines when a form should be deleted (therefore circumventing the need for a custom checkbox).
However, if you have a checkbox on the Form object, it allows you to provide end users with the ability to delete forms, using Self Field Links.
There are many ways to accomplish the deletion / flagging of Forms - and the proper method for doing so depends on your requirements. With that said, the purpose of this article is to demonstrate that we can flag certain forms, in certain situations, to represent that they may no longer be relevant. In which case, we can create processes for deleting them if we wish.
Considerations for Deleting Form Records
- Because all of the Answer records are deleted when a Form record is deleted, an admin should be mindful of not exceeding DML limits when deleting forms en masse. Calculate how many forms you may be deleting at once, multiplied be each forms Answer quantity, and ensure this number is below Salesforce's DML limitations.
- If you delete a form record while it is still on a user's mobile device, and that user attempts to sync the form (perhaps after returning from an offline state), the user may experience an error or syncing issues. Consider only deleting forms which are not available on mobile, to ensure that end users don't experience errors.