Example of Configuring MDF Pre-Approval Validation
Since brand owners don't have identical approval processes, MDF provides a flexible and quick way to create pre-approval validations that meet your specific business needs. If your business processes change, you're able to change your validations accordingly.
Sales administrators can use Application Composer to create customer-defined validations that run before an approver takes action on a submitted MDF request or MDF claim. In this example, a sales administrator for a brand owner creates a validation that ensures MDF requests can only be approved if a budget is associated to the request. When this validation is activated, approvers receive an error message when they try to approve a MDF request that doesn't have an associated budget.
Each human task action requires a separate validation. After you create the validation in Application Composer, you must create a profile option whose value is the name of the object function that will be invoked when the human task action executes. You can configure validations for the following human task actions:
-
Return
-
Approve
-
Reject
-
Withdraw
To create the pre-approval validation, sales administrators must:
-
Create the validation in Application Composer as an object function under the MDF request object, server scripts link.
-
Create a site level profile option with a value that's the same as the name of the object function that will be invoked.
Create and Configure the Validation
Use the following steps to create and configure a validation for MDF requests that ensures a MDF request can only be approved if a budget is associated to it.
-
Sign in with your sales administrator credentials.
-
Ensure that you're in a sandbox.
-
Navigate to Application Composer.
-
From the list of Standard Objects, select MDF Request.
-
Select Server Scripts, then select Object Functions, and click Create.
-
On the Object Function page, provide the following:
-
Function Name: type a name for the function, such as validateMDFRequest.
-
Return: select String.
-
-
In the Parameters area, click Create and provide the following:
-
Name: type a name for the parameter, such as parameter.
-
Type: String.
-
-
In the Function Body area, type the following:
def context = parameter?.tokenize(';='); //Replace 'parameter' with whatever parameter name is defined in the object function, in this case it is 'parameter'. .def stage = context[1];def participant = context[3];def user = context[5];if(BudgetId ==null && stage == 'SoaOLabel.RequestBudgetFundRequestApprovalStageTwo'){ // This condition is on the second stage which is final stage for the seeded flowreturn "A Budget must be associated to Fund Request before the final approval"; //Error message to be shown on UI if the validation fails}return null; //Return null otherwise, which means the validation is successful. -
Validate the script and click Save and Close.
Create and Configure the Profile Option
Use the following steps to create and configure the profile option for the previous validation.
-
Sign in with your sales administrator credentials.
-
Ensure that you're in a sandbox.
-
Navigate to Setup and Maintenance.
-
Search for and select Manage Profile Options.
-
Create a new profile option with the following values:
-
Profile Option Code: MKT_FUNDREQUEST_APPROVE_VALIDATION_OBJFUNC (This is the code for Fund Request approve validation; the codes are predefined for object/action validation and must be defined exactly the same)
-
Profile Display Name: Fund Request Approve Validation Object Function
-
Application/Module: Marketing
-
Start Date: Provide a start date for the validation.
-
-
Click Save and Close.
-
Select the Enable check box for the profile option at the Site level only and select the Updatable check box at the site level only.
-
Click Save and Close.
-
Test the validation by approving the FundRequest without providing the Budget. It should display the message what was returned in the groovy. Once you complete the testing you can publish the sandBox.