Expand my Community achievements bar.

SOLVED

Send delivery via javascript and show in dashboard Panel

Avatar

Level 1

Hi all. 

I would like to know if there is any way to send email via javascript code and show the results in the dashboard panel.

This is my workflow:

 

Captura.PNG

Payload to send trought htttp request of each contact

{
"request_id":"<%= (String("xxx") + message.id.toString().replace(/,/g, "")).slice(( String("123") + message.id.toString().replace(/,/g, "")).length - 10) %>-<%= substring(1, 9) %>",
"original_dt":"<%= formatDate(new Date(), "%4Y-%2M-%2D") %>T00:00:00.000Z",
"config":{
"service_type":"ssssxd",
"asap":false,
"start_at":"<%= formatDate(new Date(), "%4Y-%2M-%2D") %>T00:00:00.000Z",
"on_behalf_of":"nsc",
"on_behalf_buno":null,
"playbook":"presms_3retries_ws",
"call_script":"always_on",
"cta":{
"offering":"TMKT",
"channel":"event_host",
"source":"Event",
"button":null,
"product_id":"<%= x.product_display_code %>",
"vin":null
},
"crm":{
"brand":"XXX",
"campaign_id":"1-9881sdakjsdjk7413468",
"campaign_name":"TEST_TEST",
"treatment_id":"1-118239140233",
"lead_ctx":"TEST_TEST",
"segment":"<%= targetData.x%>",
"event_name":"test",
"event_location":null
}
},
"contact":{
"camp_member_id":null,
"carmen_id":"<%= contactES.contactProfilerES.src_contact_id %>",
"ucid":null,
"Salutatio":"<%= contactES.contactProfilerES.gender %>",
"test":"<%= contactES.first_name.toUpperCase() %>",
"test":"<%= contactES.last_Name.toUpperCase() %>",
"test":"<%= contactES.second_last_Name.toUpperCase() %>",
"test":"IDESP",
"test":null,
"email":"<%= contactES.main_email_address %>",
"telephone":"<%= contactES.mobile_phone_number %>",
"zipcode":null,
"consents":{

}
}
}

 

 http.header["X-WSSE"] = l("test"'t');
 http.header["Content-Type"] = "application/json; charset=utf-8";
 http.method = "POST";
 http.body = JSON.stringify(body);
 http.execute();
 
 
After run this code i can receive the response from the api ok.
 
The problem is that adobe campaing  cant show this response data and the statistics in the Dashboard Panel.
Is there any way to show the statistics of the delivery htttp request in the dashboard?
 
Thanks for all .
 
Regards
 
        

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi, 

you can create a delivery via javascript and add it to the campaign; then the delivery will show up in the campaign dashboard. Example:

var deliveryTarget = <delivery>
  <targets>
    <deliveryTarget>
      <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
        <where>
          <condition expr='[@folder-id] = 1050'/>
        </where>
      </targetPart>
    </deliveryTarget>
  </targets>
</delivery>;    

var templateName = 'myTemplate';
    
var deliveryXml = nms.delivery.CreateFromModel(templateName, deliveryTarget);
var delivery = nms.delivery.create(deliveryXml);
var operationId = 1234;

delivery.operation_id = operationId;
delivery.scheduling.validationMode = "auto";
delivery.validation.useBudgetValidation = false;
delivery.validation.useContentValidation = false;
delivery.validation.useTargetValidation = false;
delivery.validation.useFCPValidation = false;
delivery.save();

nms.delivery.PrepareFromId(delivery.id);

In the code above the operationId is the operation/@id attribute of the campaign.

Best regards, Tobias

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi, 

you can create a delivery via javascript and add it to the campaign; then the delivery will show up in the campaign dashboard. Example:

var deliveryTarget = <delivery>
  <targets>
    <deliveryTarget>
      <targetPart type='query' exclusion='false' ignoreDeleteStatus='false'>
        <where>
          <condition expr='[@folder-id] = 1050'/>
        </where>
      </targetPart>
    </deliveryTarget>
  </targets>
</delivery>;    

var templateName = 'myTemplate';
    
var deliveryXml = nms.delivery.CreateFromModel(templateName, deliveryTarget);
var delivery = nms.delivery.create(deliveryXml);
var operationId = 1234;

delivery.operation_id = operationId;
delivery.scheduling.validationMode = "auto";
delivery.validation.useBudgetValidation = false;
delivery.validation.useContentValidation = false;
delivery.validation.useTargetValidation = false;
delivery.validation.useFCPValidation = false;
delivery.save();

nms.delivery.PrepareFromId(delivery.id);

In the code above the operationId is the operation/@id attribute of the campaign.

Best regards, Tobias