Highlighted

updating mbox parameters using at.js

Chand856

21-11-2017

Please help me on the below.

i know in case of mbox.js , we have mboxUpdate() function to update mbox parameters . What is the similar one if we use at.js . I tried adobe.target.applyOffer and it is not working . Please provide some sample code

Replies

Amelia_Waliany

Employee

21-11-2017

Hi there and thanks for your question! You might find this article in the Target Documentation helpful. Feel free to reach out again if you have any other questions!

Highlighted

Chand856

27-11-2017

Hi,

mboxUpdate

Executes the request and applies the offer to the element identified by the nodeId in the mboxDefine(). Can also be used to update an mbox initiated by mboxCreate. Built into at.js mostly to ease the transition from mbox.js to at.js. mboxDefine()/mboxUpdate() could be replaced byadobe.target.getOffer() <https://marketing.adobe.com/resources/help/en_US/target/ov2/r_target-atjs-getoffer.html#reference_C81525D1598A4A1199740DCAB81A7FDF> and adobe.target.applyOffer()<https://marketing.adobe.com/resources/help/en_US/target/ov2/r_target-atjs-applyoffer.html#reference_BBE83F513B5B4E03BBC3F50D90864245> using the selector option.

I tried using the two functions listed above and not able to update the parameters of the global mbox. The below code is showing error in console “Offers is missing” , though it is mentioned.

adobe.target.getOffer ({

"mbox": "target-global-mbox",

"success": function(offers) {

adobe.target.applyOffer( {

"mbox": "target-global-mbox",

"offers": [{

"actions" :

"content" : [{

"profile.recurringClient" : +digital_data.previousBookingInfo.recurringClient,

"profile.familyBooking" : +digital_data.previousBookingInfo.familyBooking

}]

}

}]

} );

Highlighted

arturc85303583

Employee

29-11-2017

hello bhanuc99794808​,

If you could provide more details regarding what are you trying to accomplish that would help us provide more concrete steps.

Regarding your question, at.js supports mboxUpdate(), however to make sure it behaves as expected, just as with mbox.js, you have to make sure that you first call mboxCreate() or mboxDefine() followed by mboxUpdate().

If you try to move away from old mbox APIs and you want to use the new at.js APIs like getOffer() and applyfOffer(), then there are a few things that you should be aware of:
getOffer() - is responsible for sending data like mbox or profile parameters to Target edge and receiving offers. All the getOffer() options are listed here: adobe.target.getOffer(options)

applyOffer() - is responsible for rendering the offers received from Target. All the applyOffer() options are listed here: adobe.target.applyOffer(options)

If you try to execute a custom global mbox request and you want to use additional parameters, here is how you can do it:

<script>

adobe.target.getOffer({ 

  "mbox": "target-global-mbox",

  "params": {

    "a": 1,

    "b": 2

  },

  "success": function(offers) { 

    adobe.target.applyOffer( {

      "mbox": "target-global-mbox",

      "offer": offers

    });

  }, 

  "error": function(status, error) {

    console.log('Request failed', status, error);

  }

});

</script>

NOTE: the params option, which you can use to send additional parameters to Target edge.

I hope this helps.