Use Case: Restricting Form Submissions With Salesforce Rollup Fields 


In this Article
Related Articles

Introduction

When creating a registration form, you may wish to restrict the number of registrations to a certain number. For example, if you only have a limited number of spaces available. While you could restrict the number of form submissions using form availability settings, you might need to have multiple events on one form. In this case, the form availability settings will not be able to differentiate between the event submissions. You can accommodate for this with custom objects and rollup fields in Salesforce. 

Please note that this use case may not suit every Salesforce setup. Our Support team is not able to assist with your Salesforce setup, so you may need to request assistance from your Salesforce admin or developer. 

This use case requires an intermediate knowledge of FormAssembly and Salesforce. If you need assistance with the FormAssembly setup, you can reach out to our Support Team. For assistance with the Salesforce setup, please contact your Salesforce administrator or developer. 


Salesforce Setup

This use case will utilize Salesforce custom objects as they are the least likely to impact your current Salesforce setup. However, they are not required to be used. If you would like to incorporate these ideas into your Salesforce setup, we recommend working with your Salesforce admin or developer to alter these steps. 

Step 1: Create an "Inventory" Object

First you will need to create a custom object which will handle the number of registrations for each event or form. We will be referring to this as your "inventory". 

  1. Go to your Object Manager in Salesforce. 
  2. Create a new Custom Object.
  3. Give your Custom Object a label such as "Inventory" and set all permissions as required by your organization. Make sure that the object is deployed and accessible by the API.

Step 2: Create a "Registration Record" Object

Next, create a custom object which will record the number of registrations for each event or form. We will be referring to these records as "registration records". 

  1. Go back to your Object Manager in Salesforce.
  2. Create a new Custom Object.
  3. Give your Custom Object a label such as "Registration_Record" and set all permissions as required by your organization. Make sure that the object is deployed and accessible by the API.

Step 3: Create a Master-Detail Relationship and Necessary Fields

  1. Open your Registration Record object from the Object Manager.
  2. Go to the Fields and Relationships tab. 
  3. Add a new field with the type "Master-Detail Relationship" and the label "Inventory". 
  4. Relate this field to the Inventory object. 
  5. Set any necessary permissions and save. 
  6. Add another field, this time with the "Number" type and the label "Number of Registrations". Allow three or more digits.
  7. Again, add any necessary permissions and save the field. 
  8. Next, open your Inventory object from the Object Manager. 
  9. Go to the Fields and Relationships tab. 
  10. Add a new field with the type "Number" and the label "Available Registrations". Allow three or more digits. 
  11. Add any necessary permissions and save the field. 
  12. Finally, add a new field with the type "Roll-Up Summary". Give this field the label "Total Registrations".
  13. For the Roll-Up field, set the Summarized Object to be your Registration Record object. 
  14. Set the Roll-Up Type to SUM with the Field to Aggregate set to the "Number of Registrations" field. 
  15. Set any necessary permissions and save the field. 

Step 4: Adding Validation Rules

Now that you have set up the necessary objects and fields, you'll need a simple validation rule! Please follow these steps.

  1. From the Inventory object in the Object Manager, select the Validation Rules tab. 
  2. Click to add a new validation rule. 
  3. Name the rule "Inventory Validation". 
  4. For the Error Condition Formula, click "Insert Field" and insert the Total Registrations field. 
  5. Add the greater than symbol to the Error Condition Formula next: ">"
  6. Last, click "Insert Field" again and insert the Available Registrations field. Your formula should now be complete and will state that the error condition will trigger when the total registrations are greater than the available registrations.
  7. Under Error Message, type in the error message of your choice. For example, "There are no more seats available at this event."
  8. Save. 

Step 5: Create an Inventory Record 

Now to put these objects to use! Create a new Inventory record with a name and a number in the Available Registrations field. For example, a dinner event with 10 available registrations. Save your new record before navigating back to FormAssembly. 


FormAssembly Setup

Now that your Salesforce objects are ready to enforce a registration cap, you'll need to connect your form to them! To do this, create any registration form of your choice or open an existing form before continuing. 

  1. If you do not have a Salesforce Connector in the On Submit position for this form, add one now by following these steps. Remember to authenticate and enable new connectors!
  2. Add a new Lookup step to your connector. 
  3. Lookup your Inventory object. For your lookup condition set the Record ID to "a formula or text" and manually add the ID of the Inventory record that you previously created. 
  4. Next, add a dependent step. 
  5. Set the dependent step to Create a new Registration Record. 
  6. Set the "relationship" to the Inventory field. 
  7. You can map any field to the Registration Record Name. For example, this could be the name or email of the registrant. 
  8. Map the Number of Registrations field in Salesforce to "a formula or text" and enter the number "1". 
  9. Save your connector. 

Now when you submit your form, the connector will create a Registration Record related to the Inventory record. The number of registrations noted in each Registration Record will be totaled in the Inventory records roll-up field. If the total number of registrations ever exceeds the number in the Available Registrations field, an error will appear and prevent the submission of the form. 

Terms of Service · Privacy Policy