Is it possible to create a Triggered Send Definition using WSProxy?

756    Asked by AyushiKhatri in Salesforce , Asked on Apr 24, 2021

I want to create a Triggered Send Definition using "createItem" method under WSProxy . However I am unable to find any examples of the same . I am fairly new to using APIs and need to refer to some working examples in order to understand the flow . Can someone please point me in the right direction?


Answered by Ben PHILLIPS

It's nicely explained in Send a triggered email using WSProxy article from sfmarketing.cloud blog.

Triggered Send object:

    YOUR_ACCESS_TOKEN          Definition_Key     email@test.com email@test.com  firstname John      

Script using craeteItem function:

To create a new TriggeredSend, we will use the createItem WSProxy function, which has three parameters:

The first parameter is the object type to perform the action on – here, we will use previously mentioned TriggeredSend object

The second parameter is a JavaScript object which represents the fields and values to set on the object when created – in below example, we will call it tsDef and use it to define the CustomerKey, Subscribers and optionally, their Attributes

The third parameter is optional and includes any properties to be set using the SOAP CreateOptions object

 var prox = newScript.Util.WSProxy(); var tsExKey = ''; //provide Triggered Send External Key var EmailAddress = ''; //pass Email Address var SubscriberKey = ''; //pass Subscriber Key var firstName = ''; //pass First Name var lastName = ''; //pass Last Name var tsDef = { TriggeredSendDefinition: { CustomerKey: tsExKey }, Subscribers: [{ EmailAddress: EmailAddress, SubscriberKey: SubscriberKey, Attributes: [{ Name: 'firstName', Value: firstName }] }] }; var res = prox.createItem('TriggeredSend', tsDef); 

Your Answer

Interviews

Parent Categories