Loading
 Experience Cloud – Feature Degradation on Lightning Web Runtime SitesRead More
The Trailblazer Community is now read-only Read More
Media Cloud
Add a Custom Interface Implementation for Budget Calculation

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.

Managed Package Icon 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
  1. From your Advertising Sales Management org, go to Settings, and click Developer Console.
  2. 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;
    
    }
    }
    
  3. From the App Launcher, find and select Interface Implementations.
  4. Click MediaBudgetBasedImpl.
  5. On the Related tab next to Interface Implementation Detail, click New.
  6. In Available Implementation, enter the name of the Apex class.
  7. Make sure that Active is selected.
  8. Save your changes.
 
Loading
Salesforce Help | Article