From Version 2.120 and up, it is now possible to trigger the automatic update of pre-existing invoices. Activation of these Optimizing Version triggers a Platform Event which you can be listened for by a Salesforce Process. Below you can find a step-by-step example of how such a process can be set up following installation of Version 2.120 or later.
Setting of the Process
Navigate to Setup
Expand the section Process Automation
Click the link Process Builder
Click the button New
Enter the Name for your new Process
Select that the process starts when A Platform Event Message is received
In your newly created process, click Add Trigger
Search for the Platform Event “OptimizerVersionActivationCompleteEvent”
Select the object “Optimizing Version“
Setup the following matching conditions
Press Save
You can add further criteria for when the process should run, as a default however you can select No criteria—just execute the actions! and give condition a name
Now select an Action. In order to trigger the pre-invoice generation select Apex → ADvendio__GenerateInvoiceController. Set the Apex variables as follows
Your process should look as follows (including any other additional criteria you may have added)
Optional: Creating a Flow
If you want to take advantage of the high customizability of Salesforce Flows, you can also use our Flow template to begin your custom Flow creation.
Navigate to Setup
Expand the section Process Automation
Click the link Flows
Click the button New Flow
Select the ADvendio Optimizer OptimizerVersionActivationCompleteFlow template
The Flow template comes with a pre-created Apex Action that will generate the PreInvoices for a given Media Campaign.
Create a new Flow adding any custom logic you wish to trigger based on the Platform Event “OptimizerVersionActivationCompleteEvent”
In order to invoke the Flow from the process, go back to the process and delete the Apex Action you created earlierCreate a new Flows Action which will invoke the Flow you just created
If your Process was already activated, you may need to clone it before you can make these changes
You will also need to pass the Media Campaign ID to the Flow, as you can see below
Activate your new process
Your process will now automatically generate pre-invoices when an optimizing version with pre-invoices is activated.