Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Numberedheadings

The Optimizer API is implemented as Apex class and is exposed as REST web service by using Salesforce standard functionality (see Apex Developer Guide for more information). For general information about the Optimizer feature, see 4.11 Optimizer . The Create Optimization functionality compares the given Campaign Items to the existing Campaign Items from the database and creates an Optimizer Version containing all the changes/differences.

Please note that this API does not create the optimizing version record in your instance. To create the necessary records please take a look at the official Salesforce documentation about the creation of records via API: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_create.htm .
At least it will be needed to set the ADvendio__Source__c field of the ADvendio__OptimizingVersion__c record and the ADvendio__OptimizingVersion__c field of the ADvendio__OptimizingChange__c records which got returned by the API (as already visible in the example code at the bottom of the page).

REST web service

URL

https://<my-domain-name>.my.salesforce.com/services/apexrest/ADvendio/ADvendio__Campaign_Item__c/CreateOptimization/

Method

PATCH

URL Params

Data Params

A JSON object with the attribute campaignItems, containing a JSON serialized list of Campaign Items.

Example: { "campaignItems":[{<Campaign Item>}, ...]}

Success Response

Code: 200

Content: A JSON serialised Optimization (ADvendio__OptimizingVersion__c) record including all Optimizer Changes (ADvendio__OptimizingChange__c)

Error Response

See Salesforce Apex REST Documentation

Logic

When creating an Optimization, the Optimizer will create an Optimizing Change record for every single changed field. Optimizing Change contains a reference to the original Campaign Item, the old value, the new value and the developer name of the field.

Special cases:

  • related lists: When changing data, that is stored in related lists (Content, Targeting Sets), the old and new values contain a comma separated list of record ids.

  • new positions: When adding new Campaign Items during the optimization process, we need to store all (required/set) fields of the Campaign Item. Since there is no existing version of that Campaign Item but we have a master-detail relationship, the Optimizer uses a random Campaign Item Id from the same Media Campaign for the Campaign Item field. In the field ADvendio__NewCiIdentifier__c a dummy Id is saved to be able to identify what change belongs to what Campaign Item in case of adding more than one Campaign Item.

Please note that this API does not create the optimizing version record in your instance. To create the necessary records please take a look at the official Salesforce documentation about the creation of records via API: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_create.htm .
At least it will be needed to set the ADvendio__Source__c field of the ADvendio__OptimizingVersion__c record and the ADvendio__OptimizingVersion__c field of the ADvendio__OptimizingChange__c records which got returned by the API (as already visible in the example code at the bottom of the page).

Pseudo code for creating the changes. This should help to collect the data for the insert via salesforce rest api:

java

Examples

Get a Session-ID


Get CLIENT_ID and CLIENT_SECRET from any connected app or create a new app in your org: App Manager -> New Connected App

Simple request

A simple request with a Campaign Item to change the Quantity from 1000 to 2000.

Call Optimizer web service


requestBody.txt


Response


Cancel an existing Campaign Item example

Call Optimizer web service

requestBody.txt

Response

Add a new Campaign Item example

A simple request to add a new Campaign Item. There has to be an existing Media Campaign with at least one Campaign Item.

Call Optimizer web service


requestBody.txt


Response

Usage in Apex


...