You are here:
Add a Custom Interface Implementation for Budget Calculation
In a line item, the budget is calculated by using the MediaBudgetBaseImpl Interface Implementation. You can add custom logic by creating an Apex class and setting it as the Implementation Interface for the MediaBudgetBaseImpl. Use this customization to tailor budget calculations to meet specific business requirements.
This is an Advertising Sales Management on Managed Package feature. For Advertising Sales
Management on Salesforce Platform, see Advertising
Sales Management on Salesforce Platform.
| REQUIRED EDITIONS |
|---|
| Available in: Lightning Experience |
| Available in: all editions |
| REQUIRED USER PERMISSIONS | |
|---|---|
| To access Media Cloud advanced features: | MediaCloudPlus Runtime |
- From your Advertising Sales Management org, go to Settings, and click Developer Console.
-
Create an archiver Apex class and run this code:
public class <Apex_class_name> implements VlocityOpenInterface{ private static final String ERROR_STATUS = 'Error'; private static final String ERROR_UNITPRICE = 'Unit price cannot be null or zero.'; private static final String ERROR_UNITQTY = 'Units per Quantity cannot be null or zero.'; public Boolean invokeMethod(String methodName, Map<String,Object> input, Map<String,Object> output, Map<String,Object> options){ try{ Double budget = (Double)input.get('Budget'); Double unitPrice = (Double)input.get('unitPrice'); if(unitPrice == 0.0){ output.put('message', ERROR_UNITPRICE); output.put('status',ERROR_STATUS); return true; } Double unitPerQty = (Double)input.get('UnitsPerQuantity'); if(unitPerQty == 0.0){ output.put('message', ERROR_UNITQTY); output.put('status',ERROR_STATUS); return true; } // Write custom business logic for calculating requested units catch (Exception ex){ Logger.debug('exception :' +ex.getMessage() + ' At Line# :' +ex.getLineNumber()); Logger.debug('exception Line#:' +ex.getLineNumber()); output.put('message',ex.getMessage()); output.put('status',ERROR_STATUS); } return false; } } - From the App Launcher, find and select Interface Implementations.
- Click MediaBudgetBasedImpl.
- On the Related tab next to Interface Implementation Detail, click New.
- In Available Implementation, enter the name of the Apex class.
- Make sure that Active is selected.
- Save your changes.
