17

GREAT NEWS!!! Firstly I want to thank SFMC Global Support, for the first time since they were Salesforce they were actually EXTREMELY helpful and quick. (Shout out to Jeff Ross) We found out that with the Script.Util.HttpRequest() function you actually CAN use GETDELETEHEADOPTIONSPATCHPOSTPUT It took a few days of both of us digging and searching, but ...


16

I did this using SSJS and eval(). I could not find a way to parse JSON in AMPscript. Also if I recall correctly JSON.parse() is not implemented in ExactTarget. There are security concerns with eval() so you should only use it with a trusted source. Here is my example, where I first use HttpGET() in AMPscript to retrieve JSON from my trusted source. %%[ ...


16

In everyday life, AMPScript is sufficient for most personalisation tasks, when it comes to emails and landing pages. SSJS offers a larger set of functions, which I mainly use for data integrations to external APIs. Briefly speaking, AMPScript is for personalisation and SSJS for development/integrations. Here are some more points: AMPscript simply and ...


15

Here's a simple Guide Template Language example: %%[ var @Json set @Json = '[{"name": "john doe","email": "john.doe@mail.com"},{"name": "jane doe","email": "jane.doe@mail.com"}]' ]%% {{.dataobject JsonVar type=variable source=@Json maxrows=20}} {{.data}} {"...


14

You need to set up a microsite page that handles the form submission and does something with the values. AMPscript has a function RequestParameter() that gets values from an HTTP Post. You take these values and insert them into your DE. A Really Simple Example Here is the simplest example I can think of to do what you need. You will have 2 microsite pages:...


14

I've been able to successfully write script activities that reference AMPScript code. The trick is to place all your AMPSript code in a separate content area and call the content area from your script activity. The script activity window can only contain SSJS code. example: <script runat="server"> Platform.Load("Core","1.1.1"); var stream = ...


13

It'd be great if the documentation was better. Unfortunately, there a very few resources outside of the SF ecosystem. IMO, you've found the best resource -- the marketing-cloud, ampscript and SSJS tags and the helpful community here on SFSE. Most AMPScript topics have been discussed and re-discussed. The powerful SFSE search can help you find some ...


11

You need to add the required Personalization Strings to your email HTML as outlined in the error message: Subscription Center: %%subscription_center_url%% Profile Center: %%profile_center_url%% One-click Unsubscribe: %%unsub_center_url%% Sender address: %%member_busname%% %%member_addr%% %%member_city%% %%member_state%% %%member_postalcode%% %%...


11

The function does allow fieldsToNull, although not very well documented. The following code should work. UpdateSingleSalesforceObject('Contact', @personid, 'fieldsToNull', 'Email')


11

Should be something like this: %%[ if (@PromoCode == "XXXX" OR @Tier == "XXX") AND @Price == "100" then ]%% %%[ endif ]%%


10

I use the SSJS function Platform.Function.ParseJSON. <script runat="server"> var str = '{ "prop1": "propVal" }'; var obj = Platform.Function.ParseJSON(str); var val = obj.prop1; </script>


10

You can still use FormatNumber-- just subtract 0.5 from the number before feeding it into FormatNumber. Something like this would probably work: FormatNumber(@OriginalNumber-0.5, "N0", "en-US") Since you subtract 0.5, a number such as 1.99 becomes 1.49 which would round down, while 2.49 would become 1.99 and round up.


10

There are a few parts to this answer. First, you have to call your ExactTarget support rep and have them enable WRAP HTTPGET URLS for your account. Second, all URLs in the HTTPGet that you want tracked must be preceeded by httpgetwrap|. So for instance, a full HTML url would look like. <a href="httpgetwrap|http://www.example.com/">. If you do not ...


10

you can not use DataView to update the subscriber status. you should use API AmpScript functions and below is the sample code for your reference. %%[ SET @Subscriber = CreateObject("Subscriber") SetObjectProperty(@Subscriber, "SubscriberKey","test@gmail.com") SetObjectProperty(@Subscriber, "EmailAddress", "test@gmail.com") SetObjectProperty(@Subscriber, "...


10

Server-Side JavaScript gives us more flexibility. We can use Ampscript in Script Activities. I have used it. I am not claiming that this is the best solution, but we can do the same using some tricky way like this: <script runat="server"> Platform.Load("core","1.1.1"); var sfUpdateString; var subId = "abc123"; // Assuming subkey is available to ...


10

You can fire the event using a REST-API call to the "POST /interaction/v1/events" endpoint. An example request looks like this: { "ContactKey": "YOUR_CONTACTS_KEY", "EventDefinitionKey":"EVENT_DEFINITION_KEY_OF_API_EVENT", "EstablishContactKey": true, "Data": { "dataForEvent1":"John", "dataForEvent2":"Doe" } } ...


10

The issue comes from the Sender Profile (SP) being processed prior to the email. This means that any variables set inside the email will not be rendered as they are set after the variable is called in the SP. The logic you used above utilizing variables from the email works for subject line and preheader as they are processed after the email, so the ...


10

As shown in the documentation (and more clearly stated in the AMPscript Guide), all math can only be done via the functions listed in the syntax guide [MULTIPLY(), SUBTRACT(), ADD(), etc.] unlike other languages that can use the operators of [-,+,*,/]. In contrast to many other scripting languages that use operators like +, -,*, and \, AMPscript uses a ...


9

Here ya go for everyone needing to know this. Here's how it is done: <p id="date" style="font-family:Georgia, serif; color:#446c5a; font-style:italic; font-size:16px; padding-top:0px; margin-bottom:0;">%%xtmonth%% %%xtday%%, %%xtyear%%</p> %%[Var @curdate, @url SET @curdate = Format(Now(), "MMddyyyy") SET @url = Concat("http://...


9

As an alternative to the "personalization" method described above, if you have the business rule "ENHANCED SENDER PROFILE" (you may need to contact support to have this enabled) turned on you can use AMPscript to pull back information from a DE. e.g. for from name %%[ VAR @fromName SET @fromName = Lookup("MySendProfilesDE","FROM_NAME", "SendProfileField", ...


9

I'd suggest using the MOD() AMPScript function. If @sum is evenly divisible by 2 then it's even, otherwise it's odd: %%[ var @i, @sum, @max set @sum = 0 set @max = 10 FOR @i = 1 TO @max DO SET @sum = Add(@sum,1) NEXT @i IF mod(@sum,2) == 0 THEN outputline(concat("<br>", @sum, " is even")) ELSE outputline(concat("<br>", @sum, " is odd"))...


9

Logging an unsub event is the way to get unsubscribes logged properly (and ultimately in the _Unsubscribe data view). You can't insert into directly into any of the data views. You'd need jobID, listID, _JobSubscriberBatchID and an encrypted or obfuscated _subscriberkey to replicate what's done on a one-click unsubscribe page. You may be able to pass and ...


9

You're not checking if the variables have been populated, your code is missing if not empty rules. I suggest trying with the following script in the original version, as it was posted by Adam on his blog: %%[ var @debug var @jid var @listid var @batchid var @email var @skey var @reason var @unsubscribeAll set @debug = 0 set @jid = AttributeValue("jobid") ...


9

Not a bullet proof solution, but I have implemented an increased level of security by using EncryptSymmetric and DecryptSymmetric, so you avoid storing the id and secret directly in Ampscript. First you create the three required assets in Key Management: Password Salt Initialisation vector You need to use the EncryptSymmetric in a different Cloud Page to ...


9

Just try it and take some of these: Documentation AMPscript Developer Guide (official documentation) The AMPscript Guide by Eliot Harper and Adam Spriggs Salesforce Stackexchange, AMPscript tag ​ Websites Gregory Gifford Mark Cassady Zuzanna Jarczyńska HowToSFMC Adam Spriggs Ivan Razine Jackson Chen ​ Twitter Corinna Cohen Chester Bullock Guilda ...


8

You can use IndexOf() function to do that. %%[ Var @str, @var, @msg /* Set the value to check */ Set @var = "Dog" /* Set the string to check */ Set @str = "MyDogIsMyFriend" /* Does it match */ if IndexOf(@str,@var) > 0 then Set @msg = "We Found It" else Set @msg = "We didn't find it" endif ]%% %%=v(@msg)=%% I've been looking for ...


8

Yes, I use Content Areas in Exclusion Scripts quite extensively where the Content Area contains 600+ lines of AMPscript code in some situations, but remember that the Exclusion Script still needs to evaluate to true, so in your Content Area you would have something like: %%[ var @result set @result = [insert here] %%%%=v(@result)=%% The output of @result ...


8

Below is a similar solution using SSJS in a CloudPage to retrieve Installed Package details from a Data Extension called 'Client_Auth_Details' to perform a v2 Auth token request. This is followed by a rest call to inject a record into a Journey and then returns the EventInstanceID as confirmation. Comments are included for context. Requirements: -V2 ...


8

Guide Template Language does this effortlessly. No need for SSJS, or awkward AMPscript process loops. The following code: %%[ var @products set @products = '[{"item":"Elastic love","sku ":"PUL1288MTL0000M","qty":1,"price":69.00},{"item":"Seashore","sku ":"PEN0576MCLMTL0U","qty":1,"price":59.00}]' ]%% <table border="1"> <tr> <th>Item&...


8

Option 1: You could retrieve the current value from the synchronized data extensions via AMPscript using the Lookup-function. As a prerequisite you need to have the desired object configured to sync to Marketing Cloud. Instead of the personalization string you would use a line similar to this: %%=Lookup('NameOfYourSyncDE','FieldYouLikeToQuery','Id', @...


Only top voted, non community-wiki answers of a minimum length are eligible