How to validate and approve offers programmatically? | Adobe Campaign Classic

adobe-campaign-offers-validate-javascript-1

Before we get into the implementation of validating and approving offers through API, let us recap how this process works as an out of the box feature.

The offers are created in the design environment and then pushed to the live environment by a technical workflow. This workflow runs every hour and publishes the offers to the live environment.

The workflow name is offerMgt and it is located in the below path.

/Administration/Production/Technical workflows/Campaign process/Offer notification (offerMgt)

Which API to use?

As discusses above, there are basically three steps required to perform offer validation and push them to the live environment. They are:

  1. Content validation: Content could be validated for each eligible representation
  2. Eligibility approval: Global status for the offer
  3. Go live: Move the offer from design to live environment

 Function : For Validation

nms.offer.Validation(
    Number      offerId,
    Number      type,
    XML         offerSpaces,
    Boolean     refused,
    String      comment
)

Parameters:

offerId	        Offer ID 
type Approval type (targeting=0, content=1) offerSpaces Offer spaces to approve (<offerSpaces _3571="3" _3572="3"/>)
refused Reject eligibility approval
comment Comment

Now that you have a background on the basic concepts of offer, let us look at one example now.

/*
Author: Prajwal Shetty
Version 2.1
Date: 12/13/2018
Purpose: To validate and approve offers 
*/

// Select the offers to validate
  var result = xtk.queryDef.create(
    <queryDef schema="nms:offer" operation="select">
      <select>
       <node expr="@id"/>
       <node expr="[offerView/@space-id]"/>
     </select>
     <where>
      <condition expr="@id=14892"/>
     </where>
    </queryDef>).ExecuteQuery(); 
 
   for each (var offer in result.offer) {
    // Build offer view validation element part
    var offerSpaces = <offerSpaces/>;
    for each (var offerView in offer.offerView) {
      offerSpaces.@["_"+offerView.@["space-id"]] = 3;
    }
 
    // Content validation 
    nms.offer.Validation(offer.@id, 1, offerSpaces, false, "");
 
    // Eligibility validation
    nms.offer.Validation(offer.@id, 0, offerSpaces, false, "");
}

In the latest builds, this Go live process is triggered automatically when the Offers are approved (even via the API as in this example) and does not need to be run manually.

So in future, if you have an implementation in which you have to perform the validation and approval of an offer through a script, then this is the way you need to do it.

Hope this helps.

error: Content is protected !!