Tip #4: Automating the Creation of Payment Request Records using Multiple Templates
If you want to create a Payment Request record for every Chargent Order, but want to use a different template for different records, you can do that too. Let’s discuss a quick use case in order to put this into context.
We have a few options here: Salesforce Flow, API, or Apex. These are all good options, but here we’re going to focus on Flow.
Why Salesforce Flow?
- It’s low code, so any Salesforce administrator should be able to get it up and running quickly
- It’s easy to maintain should future edits be needed
- It’s flexible. Salesforce is retiring Workflow Rules and Process Builder, and their replacement is Flow. As such, they’ve built it with a robust feature set. It handles automations that historically required code and professional developers, and will accommodate just about every use case
So let’s use Flow to achieve this. But first, we need to ensure that the “Create Payment Request Record for All Orders” option is disabled in the Payment Request Setup wizard for all templates. That option only works for one template at a time, and our Flow is going to handle this going forward.
Next, we’ll get started on our Flow by navigating to “Process Automation,” then “Flows” in Salesforce Setup. We’ll click the [New Flow] button and choose “Record-Triggered Flow.”
We’re picking this option because we want a Payment Request record created each time a Chargent Order record is created or edited to meet specific criteria.
We’ll choose Chargent Order for the Object, and for the “Configure Trigger” option, we’ll select “A record is created or updated.”
For the “Set Entry Conditions” section, we’re going to choose “All Conditions Are Met,” and we’ll add a single condition for this example. We’ll choose the “Payment Title” field on the Chargent Order object, the “Contains” Operator, and we’ll enter the word “Event” in the Value field. What this means is that if a Chargent Order record is created with or edited to include the word “Event” in that Payment Title field, this Flow will trigger.
We’re going to choose the “only when a record is updated to meet the condition requirements” option so that this only triggers on record edits where the condition WASN’T already met prior to the edit.
Finally, we’ll optimize this Flow for “Actions and Related Records” so that it only triggers after a record has been saved. Our Start for this Flow is complete.
Next we’ll add an element by clicking the plus symbol. We scroll down to the Data section and choose “Create Records.”
We’ll give this event a label that represents what it will accomplish. For this example, we’ll enter “Create Event Payment Request Record.”
Then we’ll choose “One” from the “How Many Records to Create” option, and we’ll choose “Use separate resources, and literal values” so that we can specify exactly which field values to populate when creating our Payment Request record. For the Object, we’ll choose “Payment Request.”
From here we’ll define which values should be populated in the fields on the record we’re creating. To do that, we’ll choose the field on the left, then either choose or enter the values on the right, clicking the [Add Field] button each time we want to set more field values.
In this example, I’ve populated the “Chargent Order” field with a variable for the Chargent Order record that triggered this Flow. I’ve populated the “Payment Request Transaction Type” field with “Charge Full Amount.” For the “Status” field I’ve chosen “Created.”
Finally, for the “Payment Template” field on the Payment Request record, I’ve copied the template name I wish to use from an existing Payment Request record, and pasted it here. This is the piece that will define which Payment Request template will be used when the Payment Request page for this record is loaded.
From here, I click the [Done] button, then save and activate this Flow.
And that’s it! Our new Flow will trigger when a Chargent Order record is created or edited to include the word “event” in that Payment Title field. When it triggers, it will create a related Payment Request record using the template that we specified. If we want to achieve the same thing for another template, we’d simply add a Decision element after our Flow Start for that other option.
From here, we can send that Payment Request link, or embed it in an invoice. Whatever makes sense for our business.