Skip to content

Instantly share code, notes, and snippets.

IF RequestParameter("submitted") == true AND RequestParameter("unsub") == true THEN
/* update contact in Sales Cloud */
SET @updateRecord = UpdateSingleSalesforceObject(
"Contact", @contactId,
"Newsletter__c", "false",
"Events__c", "false",
"Offers__c", "false",
"HasOptedOutOfEmail", "true"
)
%%[
SET @contactId = _subscriberkey
IF RequestParameter("submitted") == true THEN
/* update contact */
SET @updateRecord = UpdateSingleSalesforceObject(
"Contact", @contactId,
"FirstName", RequestParameter("firstname"),
"LastName", RequestParameter("lastname"),
%%[
SET @contactId = _subscriberkey
IF NOT EMPTY(@contactId) THEN
/* fetch data from Sales Cloud to show in the form */
SET @subscriberRows = RetrieveSalesforceObjects(
"Contact",
"Id,FirstName,LastName,Email,Newsletter__c,Events__c,Offers__c,HasOptedOutOfEmail",
<html>
<body>
<h2>Update your profile:</h2>
<form>
<label>First name: </label><input type="text" name="firstname"><br>
<label>Last name: </label><input type="text" name="lastname"><br>
<label>Email: </label><input type="text" name="email"><br>
<h2>Update your subscriptions:</h2>
<label>Newsletter: </label><input name="newsletter" type="checkbox"><br>
<label>Events: </label><input name="events" type="checkbox"><br>
HTTP/1.1 202 Accepted
{
"tokenId": "c21NCNSDN2sMMWM2miosdjEHH",
}
Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
POST /sms/v1/messageContact/MzA6Nzg6MA/send
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"mobileNumbers": [
"13175551212"
],
"Subscribe": true,
<script runat="server">
Platform.Load("Core","1.1.1");
try {
//API authentication
var authEndpoint = ""; //provide authentication endpoint
var payload = {
clientId: "", //provide Client Id
clientSecret: "" //provide Client Secret
};
Dear Customer,<br>
Here are the details of your order:<br>
<script runat="server">
Platform.Load("core","1");
var custId = "0031t000005D98UAAS"
var OrdersDE = DataExtension.Init("Orders");
var rows = OrdersDE.Rows.Lookup(["CustomerId"], [custId]);
<script runat="server">
Platform.Load("core","1");
var custId = "0031t000005D98UAAS"
var OrdersDE = DataExtension.Init("Orders");
var rows = OrdersDE.Rows.Lookup(["CustomerId"], [custId]);
if(rows.length >= 1) {
for (i = 0; i < rows.length; i++) {
OrderItem = rows[i]["OrderItem"];
<script runat="server">
Platform.Load("core","1");
var custId = "0031t000005D98UAAS"
var OrdersDE = DataExtension.Init("Orders");
var rows = OrdersDE.Rows.Lookup(["CustomerId"], [custId]);
</script>