Stay up to date with Email360 docs and product news.
Enables the AMP function HTTPRequestHeader in SSJS
This function returns a specified header from an HTTP request. This function is only available in landing pages, microsites and CloudPages. It cannot be used in other Marketing Cloud applications.
NOTE: Only headers that are available in the page request return a value. For example, if a user pastes a URL into a web browser instead of clicking on a page hyperlink (from another web page), the Referer header value will be empty.
Enables the AMP function UpdateSingleSalesforceObject in SSJS
This function updates a record in a Sales or Service Cloud standard or custom object. The function returns 1 if the record is updated successfully or 0if it fails.
NOTE: Additional API field name and value pairs can be appended as arguments.
NOTE: Certain Salesforce objects enforce record-locking when a record is modified, to ensure the referential integrity of data. This applies to records that have a relationship to lookup records in a different object. If the function is used to asynchronously update multiple records (for example, the function is included in an email) and the object has lock contention, the records may fail to update.
(string)
API name of the Salesforce object.
(string)
Record identifier to update
(array)
Array of name-valiue pair to update
Enables the AMP function RetrieveSalesforceObjects in SSJS
This function retrieves fields from a record in a Sales or Service Cloud standard or custom object. The function returns a row set of fields.
NOTE: Additional API field name, comparison operator and value sets can be appended as arguments. However the function joins these additional sets using AND clauses.
NOTE: This function should only be used in applications that do not require a high volume of requests or return a large number of records; for example, an email send to a small audience, a Triggered Send, or the retrieval of a single record on a landing page.
NOTE: The function may take several seconds to execute, impacting email send performance and may result in a timeout if the request volume is high for example; using a process loop to execute the function multiple times or returning a large number of rows. Unlike other AMPscript functions that return a row set — for example, LookupRows which limits the number of rows to 2000 — there is not the same type of limitation on the number of rows returned by this function.
(string)
API name of the Salesforce object.
(array)
Comma-separated array of API field names to retrieve
(array)
Set of arrays where each array is one set of filter
object
:
The result of the request
Enables the AMP function CloudPagesURL in SSJS
Provides a way for users to reference a CloudPages URL in an account from an email message. Use this function in an email to pass information via a URL in an encrypted query string. For example, you could share a single unsubscription or profile center page for use in any sent email message. This method passes information in an encrypted query string without passing subscriber information or values in clear text.
(integer)
Page ID for the landing page reference in the URL.
Locate this value on the appropriate CloudPage content
details page. Page ID can be from the enterprise (EID)
or the business unit (MID) where the function is used.
(object)
Name-Value pair for additional parameters included
in encrypted query string
string
:
A full URL
Enables the AMP function SHA1 in SSJS
This function converts the specified string into a SHA1 hex value hash.
(string)
String to convert
(string
= UTF-8
)
Character set to use for character-encoding.
Valid values are UTF-8 (default) and UTF-16
string
:
The string as a SHA1 hex value hashed
Enables the AMP function SHA256 in SSJS
This function converts the specified string into a SHA256 hex value hash.
(string)
String to convert
(string
= UTF-8
)
Character set to use for character-encoding.
Valid values are UTF-8 (default) and UTF-16
string
:
The string as a SHA256 hex value hashed
Enables the AMP function SHA512 in SSJS
This function converts the specified string into a SHA512 hex value hash.
(string)
String to convert
(string
= UTF-8
)
Character set to use for character-encoding.
Valid values are UTF-8 (default) and UTF-16
string
:
The string as a SHA512 hex value hashed
Enables the AMP function DataExtensionRowCount in SSJS
This function returns the number of rows in the specified Data Extension.
NOTE: This function will not return row counts from the System Data Views.
(string)
Name of the Data Extension from which to retrieve a row count
Copyright: email360
Author: Sascha Huwald
Since: 2020
Version: 1.0.0
License: MIT
Collection of wrapper functions for the usage of Cloudpages.
(object?)
Used to update the settings object with a custom setting object
// initialise a new cloudpage instance
var cp = new cloudpage();
// initialise a new cloudpage instance with a login requirement
var cp = new cloudpage('login');
// initialise a new cloudpage instance with a jwt token requirement
var cp = new cloudpage('jwt');
Holds the payload for each call
Wrapper to use for JWT authentication.
Requires a JWT token as a request parameter either as POST or GET. If token is invalid or not given, a redirect to the error page will occur. Required parameter name: 'jwt'
NOTE: JWT token cannot be used in conjunction with CloudPagesURL as the function cannot handle "=" characters which are used as padding in a base64 encoded string. Use a standard GET URL parameter instead.
Wrapper to use for LOGIN authentication.
Requires a cookie as a JWT token. Name of the cookie can be set in the settings. Requires a login page to generate a token after successfully authenticated.
The default login page can be set in thr config: cp.login.
Validate the payload against QueryStringParameter.
If QueryStringParameter was found it is save at runtime to cp.payload. E.g.: cp.payload.qs.subscriberKey.
Generate a new JWT token.
(string)
Page ID (KEY) inside the Authentication DataExtension to fetch the salt.
(number?)
Expiration time in seconds.
(object?)
Additional payload added to the token.
(array?)
Array of full website URI's to have access to. If not given, the new token will
have access to all page protected by JWT.
string
:
A new JWT token.
Log an error to a DataExtension
Centralised version of error logging in SSJS script. Not recommended in batch Emails - use AMP error log for this purpose instead. On error, a record will be written to the error log DE.
This function requires a DataExtension defined in settings.de.logError
(object)
Holds the data for the error log.
Name | Description |
---|---|
o.method string
|
The method calling the error. |
o.message string
|
The error message for better understanding of the error. |
o.source string
|
A detailed name of the error origin. E.g. [Email] Survey. |
o.subscriberKey string?
|
If given, the subscriberKey triggering the error |
o.jobid number?
|
The JobId if the error is caused from an email sent. |
o.listid number?
|
The ListId if the error is caused from an email sent. |
o.batchid number?
|
The BatchId if the error is caused from an email sent. |
o.sourceType string?
|
The SourceType. e.g. Email, Web, CRM. |
o.raiseError boolean?
|
Indicates whether an error should be raised to stop an email from sending out. Only works in Email Studio. A value of true skips the send for current Subscriber and moves to next Subscriber A value of false stops the send and returns an error. |
string
:
The eventId for the error.
Log a warning to a DataExtension.
This function requires a DataExtension defined in settings.de.logWarning.
(object)
Holds the data for the warning log.
Name | Description |
---|---|
o.method string
|
The method calling the warning. |
o.message string
|
The warning message for better understanding of the warning. |
o.source string
|
A detailed name of the warning origin. E.g. [Email] Survey. |
o.subscriberKey string?
|
If given, the subscriberKey triggering the warning |
o.jobid number?
|
The JobId if the warning is caused from an email sent. |
o.listid number?
|
The ListId if the warning is caused from an email sent. |
o.batchid number?
|
The BatchId if the warning is caused from an email sent. |
o.sourceType string?
|
The SourceType. e.g. Email, Web, CRM. |
string
:
The eventId for the warning.
Check if value is an object.
(any)
The value to check.
boolean
:
Add units to a datetime
(date)
The original date
(number)
Numbers to add to the dt
(string
= Hours
)
Units to add
['Seconds','Minutes','Hours','Days','Months','Years']
.
date
:
The new date
Subtract units to a datetime
(date)
The original date
(number)
Number to subtract from the dt
(any)
(string
= Hours
)
Units to subtract
['Seconds','Minutes','Hours','Days','Months','Years']
.
date
:
The new date
Remove time from given DateTime
(date)
The datetime
date
:
Date
Get the current UTC Date
date
:
UTC Date
Get the current UnixTimestamp
number
:
The current UnixTimestamp in UTC
Get the difference in hours between two datetimes
number
:
hours difference
Get the difference in days between two datetimes
number
:
days difference
Convert minutes into a human readable form
(number)
Miniutes given
string
:
Group an array of object by one property
array
:
the grouped array
Check if a string is in the object
boolean
:
Check if a string is in the object) recursively.
boolean
:
Shuffles an array.
(array)
Array containing the items.
array
:
The suffeled array
Delete item in array.
array
:
The new array
Create AMP variables from an object
(object)
A name and value object.
// creates 3 AMP variables
createAmpVariables({
email: 'info@email360.io',
source: 'Email360',
url: 'http://www.email360.io'
});
SSJS wrorkaround to use console server side
Display the message appropriate to the Debugging Mode
(string)
The message to be displayed.
Wait for n Miliseconds
(number)
Miliseconds to sleep
Validates if the contentBlock with the given key exists
(string)
The ContentBlockKey
boolean
:
Returns the current page URL optional with parameters
(boolean
= false
)
Keep parameters from the url
string
:
Verify if the given string is a possible SFMC default CustomerKey
(string)
The string to be tested
boolean
:
Perform an HTTP request allowing the usage of API methods.
(string)
The method to use e.g: POST, GET, PUT, PATCH, and DELETE
(string)
The url to send the request to
(string?)
The contentType to use e.g: application/json
(object?)
A payload for the request body
(object?)
Header values as key value pair
object
:
Result of the request
Generate a random string for the given fieldType
Allowed types: Decimal,EmailAddress,Boolean,Number Date, Phone, Locale, Text.
(string)
Defines the data to be generated.
string
:
The generated data string
Copyright: email360
Author: Sascha Huwald
Since: 2020
Version: 1.0.0
License: MIT
Collection of wrapper functions for the usage of the Salesforce Marketing Cloud REST API.
(object?)
Used to update the settings object with a custom setting object
// initialise a new sfmcApi instance
var rest = new sfmcApi();
Trigger a journey entry event.
Requires a DataExntesion (DE) to be used in conjunction with a journey entry source.
(string)
The ID that uniquely identifies a subscriber/contact
(string)
Find the EventDefinitionKey in Event Administration after the event is created and saved.
(object)
Properties of the event. Only required if defined in a custom event or by the event.
boolean
:
// trigger a journey
var rest = new sfmcApi();
var data = {
'email': 'info@email360.io',
'name': 'John'
};
var resp = rest.triggerJourneyEvent(data.email,'APIEvent-b14f22b4-79f2-e573-ebaf-53ad4fa60f63',data);
Create an image asset
(string)
A base64 encoded image file
(string)
The name of the image
(string)
The image type e.g.: jpg, png
(string)
A brief description about the file
object
:
Result set of the request.
Gets a list of send definitions.
Note: Accepted filter values are active, inactive, or deleted. Valid operations are eq and neq. Example: 'status neq active'
object
:
Result set of the request.
var rest = new sfmcApi();
// retrieve all Send Definitions
var resp = rest.retrieveSendDefinitions(null,true);
// retrieve only with status not equal to active
var resp = rest.retrieveSendDefinitions({filter:'status neq active'});
Email preview by SubscriberId or SubscriberKey
This call will output a rendered version of the email utilizing information stored in Contact Attributes (aka Subscriber Attributes) only.
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The contact id of your subscriber (aka SubscriberID or SubscriberKey)
object
:
Result set of the request.
var rest = new sfmcApi();
// use SubscriberKey
var resp = emailPreviewContact(23141,"key:03ABDDST67SEA8")
// use SubscriberId
var resp = emailPreviewContact(23141,"id:1241157")
Email preview by List
This call will output a rendered version of the email utilizing the architecture of a list (but not a specific contact).
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your list (can be found in UI or retrieved by API)
object
:
Result set of the request.
Email preview by ListSubscriber
This call will output a rendered version of the email utilizing contact information (via ContactID) stored in a specific list or group (assigned by ListID or GroupID).
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your list (can be found in UI or retrieved by API)
(string)
The contact id of your subscriber (aka SubscriberID)
object
:
Result set of the request.
Email preview by ListSubscriber
This call will output a rendered version of the email utilizing contact information (via ContactID) stored in a specific list or group (assigned by ListID or GroupID).
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your list (can be found in UI or retrieved by API)
(string)
The subscriberKey
object
:
Result set of the request.
Email preview by DataExtension and SubscriberId
This call will output a rendered version of the email utilizing contact information (via ContactID) stored in a specific data extension (assigned by DE ID).
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your data extension ( retrieved by API)
(string)
The SusbcriberID
object
:
Result set of the request.
Email preview by DataExtension and SubscriberKey
This call will output a rendered version of the email utilizing contact information (via ContactID) stored in a specific data extension (assigned by DE ID).
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your data extension ( retrieved by API)
(string)
The SubscriberKey
object
:
Result set of the request.
Email preview by DataExtension row
This call will output a rendered version of the email utilizing a row number (assigned by inside of the specified data extension
(string)
The id of your email (can be found in UI or retrieved by API)
(string)
The id of your data extension ( retrieved by API)
(string)
The row id of the record to use inside the DataExtension
object
:
Result set of the request.
Send a test email
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution.
The route has no ownership internally, and could stop working without notice.
Note, the Send Classification, Delivery Profile and Sender Profile IDs will need to be collected via the associated SOAP API objects
or via UI as there currently is no REST endpoint that can gather this information. In the UI copy the URL for your
Send Classification and use the 18 digigt parameter id "g"
(number)
The emailId used for the send. This can be obtained
via the UI or by using the personalised string %%_emailid%% inside an email
(array)
An array of recipients to send the test email to
(object)
The dataSource for the call. Please reference the example
(string)
The ID assigned to a Send Classification (Can be found in the UI as described above)
(string?)
The ID assigned to a Delivery Profile (Can be found in the UI as described above)
(string?)
The ID assigned to a Sender Profile (Can be found in the UI as described above)
(string
= "[Test]: "
)
A prefix attached in front of the subject
object
:
Result set of the request.
var rest = new sfmcApi();
var recipients = [
'info@email360.io'
];
// Send a test email rendered with a profile from a subscriberId inside a specific list
var dataSource = {
contact: "id:1234567", // subscriberId
type: "List",
id: 1234 // list id
};
var resp = rest.sendTestEmail(3321,recipients,dataSource,"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
// Send a test email rendered with a profile from a subscriberKey inside a dataExtension
var dataSource = {
contact: "key:03ad24jd81ja74grhe", // subscriberKey
type: "DataExtension",
id: "key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" // External Key of the DataExtension
};
var resp = rest.sendTestEmail(3321,recipients,dataSource,"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
// Send a test email rendered with a profile of a DataExtension Row
var dataSource = {
row: 1, //The row number to use from the given DataExtension
type: "DataExtension",
id: "key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" // External Key of the DataExtension
};
var resp = rest.sendTestEmail(3321,recipients,dataSource,"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
Initiates a message to one or more mobile numbers.
In order to be able to programmatically trigger text messages, MobileConnect
needs to be enabled in Marketing Cloud’s Mobile Studio. The phone number must use the correct
format for the designated country code. For example, a mobile number from the United States must include the numerical
country code 1 and the area code, eg: 13175551212.
To ensure that the mobile number exists for the contact and that the contact subscribed to the specified keyword on your
short code, set the Subscribe and Resubscribe values to true and specify the keyword parameter.
(string)
Message Id provided for the messageContact
(array)
An array of one or more mobile numbers
(string?)
The keyword must align with code on message. Required when subscribe and/or resubscribe are true.
(object?)
Key-Value pair for additional params to set. See SFMC for more information
object
:
Result set of the request.
Retrieves the overall delivery status of a message to a contact.
(string)
Message Id provided for the messageContact
(string)
Token Id returned from triggerSMSMessage
object
:
Result set of the request.
Create a Script Activity
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The name of the SSJS script
(string)
The SSJS script to create
(number?)
The folder id the script will belong to. Default the default Scripts folderId from settings
(number?)
A brief description about the script
object
:
Result set of the request.
Retrieve a specific Script Activity
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The ssjsActivityId for the scriptActivity or the name
object
:
Result set of the request.
Retrieve all Script Activities
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
object
:
Result set of the request.
var rest = new sfmcApi();
// retrieve all ScriptActivities
var resp = rest.retrieveScriptActivities(null,true);
// retrieve page 2 with a pagesize of 10
var resp = rest.retrieveScriptActivities({page:1,pagesize:10});
Retrieve all Script Activities inside a folder
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The folderId to retrieve all activities for
object
:
Result set of the request.
Validate a Script
This will let you validate your SSJS prior to creation or update inside the system.
The return is a boolean value, essentially pass/fail. Please note this is just for validation of
the code, it does not verify the dependents (content areas, DEs, etc.) so it does not
guarantee there will be no errors when run.
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution.
The route has no ownership internally, and could stop working without notice.
(string)
The script to validate
boolean
:
Update an existing Script Activity
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The ssjsActivityId for the scriptActivity or the name
(object)
Object array with the data to update
object
:
Result set of the request.
Starts a Script Activity
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The ssjsActivityId for the scriptActivity or the name
boolean
:
Delete a Script Activity
Note: This is an internal only route, that currently is NOT supported. It should only be used in production environments wiht caution. The route has no ownership internally, and could stop working without notice.
(string)
The ssjsActivityId for the scriptActivity or the name
boolean
:
Copyright: email360
Author: Sascha Huwald
Since: 2020
Version: 1.0.0
License: MIT
Collection of wrapper functions for the usage of WSProxy.
WSProxy functions library in server-side Javascript for
Salesforce Marketing Cloud (SFMC).
Note: WSProxy can only be used in non sending enviroment.
(number?)
The BuisnessUnit MID for enterprise integrations.
In order to access other business units, the
library must be added to the master Business Unit.
(object?)
Used to update the settings object with a custom setting object
// initialise a new wsproxy instance
var prox = new wsproxy();
The WSProxy API instance.
this.api.retrieveItem()
Retrieves all retrievable columns for the given object.
(string)
The SFMC Object to retrieve cols from.
array
:
A list of al retrievable columns.
// retrieve cols for DataExtension
var cols = prox.retrievableCols('DataExtension');
Match cols with request result of a retrieve
A retrieve request result is returning many informations which are not useable if the same object will be used to create or update informations. This function takes the retrieveable cols and match the values against the original request result.
(array)
Array of retrievebale cols. E.g.: this.retrievableCols('asset')
(array)
A retrieve request result
array
:
A modified retrieve request
Create a DataExtension within SFMC.
Sample list of the field array required to generate the DataExtension
[ { "Name": "Text", "FieldType": "Text", "MaxLength": 50, "DefaultValue": "Hellow world" }, { "Name": "Number", "FieldType": "Number" }, { "Name": "Date", "FieldType": "Date" }, { "Name": "Boolean", "FieldType": "Boolean", "DefaultValue": false }, { "Name": "Email", "FieldType": "EmailAddress" }, { "Name": "Phone", "FieldType": "Phone" }, { "Name": "Decimal", "FieldType": "Decimal", "MaxLength": 18, "Scale": 2 }, { "Name": "Locale", "FieldType": "Locale" } ]
For a full and up to date list of available field types, visit Salesforce Marketing Cloud documantation.
(string)
Name of the new DataExtension.
(array)
Fields to be created within the DataExtension.
(number
= 0
)
Folder ID within SFMC to place the DataExtension.
object
:
Result set of the request.
// Create a new DataExtension inside the folder DataExtensions
var prox = new wsproxy();
var resp = prox.createDataExtension('MyNewDataExtension', [{
"Name": "Text",
"FieldType": "Text",
"MaxLength": 50,
"DefaultValue": "Hellow world"
}]);
Create a DataExtension with "num" random records.
(string)
The name of the new DataExtension
(number)
Amount of random records
(number
= 0
)
Folder ID within SFMC to place the DataExtension.
object
:
Result set of the request.
// Create a new demo DataExtension inside the folder DataExtensions with 100 random records
var prox = new wsproxy();
var resp = prox.createDataExtensionDemo('MyNewDataExtension', 100);
Retrieve informations about a single DataExtension.
(string)
The identifier for the DataExtension. Name or customerKey.
object
:
Result set of the request.
// Retrieve informations about a sepcific DataExtension
var prox = new wsproxy();
var resp = prox.retrieveDataExtension('MySampleDataExtension');
// using a customerKey
var resp = prox.retrieveDataExtension('53b54b8a-b604-4fc2-90x9-33eec99c8a93');
Retrieve the ModifiedDate of the given DataExtension.
Note: ModifiedDate is the the last modification of the properties for the given DataExtension. This does not apply to changes of the data within the DataExtension.
(string)
The identifier for the DataExtension. Name or customerKey.
(string | NULL)
:
The ModifiedDate of the DataExtension or NULL
Find DataExtension(s) which have no folder allocation
If a folder has been deleted and it contained any DataExtension, these DataExtension will no longer be visible in the UI as their shared CategoryID is referring to a non-existing folder.
object
:
Result set of the request.
Copy a DataExtension
(string)
The identifier for the DataExtension. Name or customerKey.
(string?)
The new name for the copied DataExtension. If null, the original name will be
used and extended by the word "Copy_"
(boolean
= false
)
Set to copy all records. Attention: Depending on the amount of records this process
can take a while and may timeout.
boolean
:
Update the properties of a DataExtenion
(string)
The identifier for the DataExtension. Name or customerKey.
(object)
Object of properties to change.
boolean
:
// changing the name of a DataExtension
var prox = new wsproxy();
var prop = { Name: "MyNewDataExtensionName" }
var resp = prox.updateDataExtension('MyNewDataExtension',prop);
// change the DataExtension to be sendable
var prop = {
IsSendable: "true",
SendableDataExtensionField: {
Name: "email", //Provide the name of the field used to establish a data relationship
DataType: "EmailAddress"
},
SendableSubscriberField: {
Name: "Subscriber Key"
} //Use "Subscriber Key" or "Email Address" depending on whether the SUBSCRIBER_KEY business rule has been turned on.
}
var resp = prox.updateDataExtension('MyNewDataExtension',prop);
Retrieve informations about a single DataExtentionTemplate.
(string)
The identifier for the DataExtentionTemplate. Name or customerKey.
object
:
Result set of the request.
// Retrieve informations about a sepcific DataExtentionTemplate
var prox = new wsproxy();
var resp = prox.retrieveDataExtentionTemplate('MySampleDataExtension');
// using a customerKey
var resp = prox.retrieveDataExtentionTemplate('53b54b8a-b604-4fc2-90x9-33eec99c8a93');
Retrieve the ModifiedDate of the given DataExtentionTemplate.
Note: ModifiedDate is the the last modification of the properties for the given DataExtentionTemplate. This does not apply to changes of the data within the DataExtentionTemplate.
(string)
The identifier for the DataExtentionTemplate. Name or customerKey.
(string | NULL)
:
The ModifiedDate of the DataExtentionTemplate or NULL
Create new records inside the given DataExtension.
To avoid the cumbersome Name-Value pair structure, the data object will be converted. Expecting the following sample object:
{ Firstname: "John", Lastname: "Peter" }
(string)
The identifier for the DataExtension. Name or customerKey.
(array)
Array of objects to add.
object
:
Result set of the request.
// create 1 record in DataExtension with name "MyDataExtension"
var prox = new wsproxy();
var resp = prox.createDataExtensionRecords('MyDataExtension',[{SubscriberKey:"123-345-123",Firstname:"John",Lastname:"Smith"}]);
// create 2 records in DataExtension with name "MyDataExtension"
var resp = prox.createDataExtensionRecords('MyDataExtension',[
{SubscriberKey:"123-345-123",Firstname:"John",Lastname:"Smith"},
{SubscriberKey:"456-654-321",Firstname:"Mike",Lastname:"Do"}
]);
Retrieve records inside a DataExtension.
In order to select all data from a DataExtension, the DataExtension field names need to be collected. After retrieving the field names, all data can be retrieved. Optional, the selection of the data can be filtered or only the first 2,500 records can be retrieved.
(string)
The identifier for the DataExtension. Name or customerKey
(object
= NULL
)
SFMC filter object
(boolean
= false
)
Retrieve more than 2,500 records.
object
:
Result set of the request.
// retrieve all records from 'MyDataExtension' where 'Number' is larger than 10
var prox = new wsproxy();
var filter = {
Property: "Number",
SimpleOperator: "greaterThan",
Value: 10
};
var resp = prox.retrieveDataExtensionRecords('MyDataExtension', filter, true)
Update or Add one or multiple records inside a DataExtension.
Update only works with a Primary Key (PK) on the given DataExtension. To avoid the cumbersome Name-Value pair structure, the data object will be converted. Expecting the following sample object:
{ Firstname: "John", Lastname: "Peter" }.
(string)
The identifier for the DataExtension. Name or customerKey.
(array)
An array of Objects with data to add.
object
:
result of the request
// update or add 1 record in DataExtension with name "MyDataExtension"
var prox = new wsproxy();
var resp = prox.upsertDataExtensionRecords('MyDataExtension',[
{SubscriberKey:"123-345-123",Firstname:"John",Lastname:"Smith"}
]);
Delete one or multiple records inside a DataExtension.
To avoid the cumbersome Name-Value pair structure, the data object will be converted. Expecting the following sample object:
{ PrimaryKey: "john.peter@gmail.com" }.
(string)
The identifier for the DataExtension. Name or customerKey.
(array)
An array of objects with primary keys to identifier the records to delete.
boolean
:
// delete one record in 'MyDataExtension' with the PrimaryKey: 'SubscrinberKey' equals '123-345-123'
var prox = new wsproxy();
var resp = prox.deleteDataExtensionRecords('MyDataExtension', [{ SubscriberKey: "123-345-123" }] )
Create DataExtension fields within the DataExtension.
A sampe field array required to generate the new field within the DataExtension
[ { "Name": "Text", "FieldType": "Text", "MaxLength": 50, "DefaultValue": "Hellow world" } ]
For a full and up to date list of available field types, visit Salesforce Marketing Cloud documantation.
(string)
The identifier for the DataExtension. Name or customerKey
(array)
Fields to be created within the DataExtension.
boolean
:
// create a field in the DataExtension 'MyDataExtension'
var prox = new wsproxy();
var fields = [{
Name: "Firstname",
FieldType: "Text",
MaxLength: 100
}];
var resp = prox.createDataExtensionFields('MyDataExtension', fields);
Retrieves a single field property of a DataExtension.
(string)
The identifier for the DataExtension. Name or customerKey
(string)
The field name to retrieve the property for
(string)
The property to retrieve
(string | NULL)
:
The porperty value for the given field name inside the DataExtension
future release
future release
Retrieve folder informations.
Attention: Folder names are not unique. If multiple folder were found, resp.Status returns OK. Each folder will create an array entry in the resp.Result set. To identify multiple folders use resp.Result.length > 1 and act accordantly. This will not occur when passing the folder id as parameter.
object
:
Result set of the request.
// retrive data folder information for the folder id 'Data Extensions'
var prox = new wsproxy();
var resp = prox.retrieveDataFolder('Data Extensions');
Retrieves all DataFolders for a given contentType.
(object?)
SFMC filter.
(object?)
Specifies the properties on the RetrieveOptions on the request.
(object?)
Specifies any remaining properties to set on the request. These
properties include “QueryAllAccounts”, “RepeatLastResult”, “RepeatAllSinceLastBatch”, and so on.
(boolean
= false
)
Retrieve more than 2,500 records.
object
:
Result set of the request.
// Retrieve every DataFolder with a parent folder ID is equal to 123 and limit the result by 2
var prox = new wsproxy();
var resp = prox.retrieveDataFolders(
{
Property:"ParentFolder.ID",
SimpleOperator: "equals",
Value: 123
},{BatchSize:2}
);
Retrieves the folder path for the requested object.
(string)
The CustomerKey for the object to retrieve the folder path for.
(string
= DataExtension
)
The SOAP ObjectType.
(string | NULL)
:
The folder path or NULL.
Check if a folder is empty based on contentType.
In order to determine if a data folder is empty, it is necessary to retrieve all objects with the same parent folderId as the requested folderId. This requires an allocation between the contentType of the folder and the required object. There is no such allocation and an object map has been created inside this method.
boolean
:
future release
Retrieve Subscriber records.
By retrieving a subscriber, you can view the applicable information for that subscriber. You can include this information in a profile center or in your own application as part of a screen that displays subscriber information
(object
= NULL
)
SFMC filter object
(boolean
= false
)
Retrieve more than 2,500 records.
object
:
Result set of the request.
// retrieve all Subscriber records where 'CreatedDate' is after '4th of January 2012'
var prox = new wsproxy();
var filter = {
Property: "CreatedDate",
SimpleOperator: "greaterThan",
Value: "2012-01-04T10:19:00"
};
var resp = prox.retrieveSubscribers(filter, true)
Update a Subscriber record
Updating an existing subscriber via the WSProxy allows you to better maintain your subscriber information while utilizing a tight integration with your system or development environment.
(array)
An array of objects with subscriber information.
boolean
:
// update a record
var prox = new wsproxy();
var resp = prox.upsertSubscriberRecords([
{
Email: 'info@email360.io',
SubscriberKey: 'SomeUniqueKey',
Attributes: {
"First Name": 'John',
"Last Name": 'Doe'
}
}
]);
Delete one or multiple records from Subscribers.
If you wish to entirely remove a subscriber from your account, you can use this call to delete the subscriber's information.
You don't need to delete a subscriber's information from your account in order to unsubscribe that subscriber from an email list. Use this call only when you wish to totally remove a subscriber's information from your account.
When you delete a subscriber, your account also loses all tracking information related to that subscriber and a new instance of that subscriber could be added to lists from which that subscriber has previously unsubscribed. For this reason, Marketing Cloud recommends editing subscribers to an unsubscribed status rather than deleting that subscriber.
(array)
An array of objects to identify the Subscriber. EmailAddress or SubscriberKey
boolean
:
Retrieve Tracking Data
In most production implementations, data volume in the account requires you to include specific JobIDs in the filter criteria of the request. If requests that don’t specify a JobID time out during processing, add a JobID in the filter. If specifying a JobID is not possible, or if your implementation requires a broad range of JobIDs, use a data extract-based procedure instead.
(string
= SentEvent
)
The event type: SentEvent, OpenEvent, ClickEvent, BounceEvent or UnsubEvent.
(object?)
SFMC filter.
(boolean
= false
)
Retrieve more than 2,500 records.
object
:
Result set of the request.
Trigger an automation with a wait timer
This call is helpful if you want to trigger an automation which may already be in progress, but you need to ensure it starts as soon as it has finished. If the automation already runs, the script will wait n milliseconds (sleep) and retry it for the duration of x repetitions (repeat).
The maximum duration is sleep * repeat.
(string)
The identifier for the Automation. Name or CustomerKey.
(number)
A number of how many repetitions
(number)
A number in milliseconds of how long the script should wait.
boolean
:
future release
Creates a TSQL Query
(string)
Name of the query
(string)
A valid TSQL statement
(string
= Update
)
Update, Overwrite, Add
(string)
The identifier for the target DataExtension. Name or customerKey.
object
:
Result set of the request.
Retrieve informations about a single QueryDefinition.
(string)
The identifier for the QueryDefinition. Name or CustomerKey.
object
:
Result set of the request.
// Retrieve informations about a sepcific QueryDefinition
var prox = new wsproxy();
var resp = prox.retrieveQueryDefinition('MySample');
// using a customerKey
var resp = prox.retrieveQueryDefinition('53b54b8a-b604-4fc2-90x9-33eec99c8a93');
Retrieve informations about an asset.
This usage of this function is limited as the retrievebale cols are not fully supported for WSProxy at this time. Only ObjectID, CustomerKey ID and Name are retrieveable but no information about the file itself. In order to retrieve more informations about the asset, use the REST API.
(string)
The identifier for the Asset. Name or customerKey.
object
:
Result set of the request.
Create a ScriptContentBlock asset
(string)
The name of the content block
(string)
The content of the file. e.g. HTML code
(string?)
A specific Customer Key to use
(string?)
A brief description about the file
object
:
Result set of the request.
Create an image asset
Note: This function will create an image but the return object does not hold any informations about the image itself. This may change in a later stage when SFMC is adding these informations. If these informations are required, use the REST API function instead.
(string)
A base64 encoded image file
(string)
The name of the image
(string)
The image type e.g.: jpg, png
(string?)
A brief description about the file
object
:
Result set of the request.
Unsuscribe a recipient
The LogUnsubEvent api call allows you to unsubscribe a subscriber and log an ‘UnsubEvent’ that is tracked against a specific job. This is mostly used for custom preference centers or unsubscribe pages.
By using this call, you are able to track back the unsubscribe to the job that the email was sent, instead of just a general non-trackable unsubscribe.
(string)
The client supplied ID that uniquely identifies a subscriber
(string)
The email address of the subscriber
(string)
The ID of the Job that sent the message.
(string)
The ID of the List that the subscriber belonged to. You can use
subscriber or publication lists (not suppression lists).
(string)
The ID of the Batch within the Job.
(string?)
The reason the subscriber is being unsubscribed.
object
:
Result set of the request.
future release
future release
Retrieve informations about a single TriggeredSendDefinition.
(string)
The identifier for the TriggeredSendDefinition. Name or CustomerKey.
object
:
Result set of the request.
// Retrieve informations about a sepcific TriggeredSendDefinition
var prox = new wsproxy();
var resp = prox.retrieveTriggeredSendDefinition('MySample');
// using a customerKey
var resp = prox.retrieveTriggeredSendDefinition('53b54b8a-b604-4fc2-90x9-33eec99c8a93');
Send a triggered email send
(string)
The CustomerKey for the TriggeredSendDefinition retrieved by retrieveTriggeredSendDefinitionCustomerKey().
(array)
Array of objects with email addresses, subscriberkey and attributes to send the email to.
boolean
:
var prox = new wsproxy();
var recp = [
{
EmailAddress: 'info@email360.io',
SubscriberKey: 'info@email360.io',
Attributes: {
FirstName: "John",
LastName: "Do"
}
}
];
var resp = prox.sendTriggeredSend(381,recp);