Hot answers tagged

16 votes

Can AMPScript parse JSON?

Here's a simple Guide Template Language example: %%[ var @Json set @Json = '[{"name": "john doe","email": "[email protected]"},{"name": "jane ...
Adam Spriggs's user avatar
  • 30.4k
10 votes

Can AMPScript parse JSON?

I use the SSJS function Platform.Function.ParseJSON. <script runat="server"> var str = '{ "prop1": "propVal" }'; var obj = Platform.Function.ParseJSON(str); ...
SebOB's user avatar
  • 807
7 votes
Accepted

Guide Template Language blocks displayed in CloudPages

It turns out that GTL is supported in CloudPages and Landing Pages after all. However, you need to reset the GTL delimiters by placing the following line at the top of your content: %%{={{ }}=}%% So ...
Eliot Harper's user avatar
  • 16.4k
6 votes
Accepted

GTL in cloudpages: #with

In your situation I would try using the {{datasource}} within GTL. Please note in mind that documentation in GTL is not widely accurate, for example around the use of Block In helpers where {{@index}},...
Brad Sapkota - altus.digital's user avatar
6 votes

Can AMPScript parse JSON?

This worked for me. Passing Recipient_List as a JSON string attribute to a email template. "[{\"name\":\"john doe\",\"email\":\"[email protected]\"},{\"name\":\"jane doe\",\"email\":\"jane.doe@mail....
Tim Graf's user avatar
  • 111
6 votes
Accepted

Guide Template Language to provide dynamic links via href attribute from JSON

I ran into the same problem. GTL will only insert a link from JSON data into an href if link tracking is disabled. I also looked for a way to let GTL parse the value out of my JSON data and then pass ...
jnoall's user avatar
  • 156
5 votes
Accepted

Dynamic Alias from Data Extension breaks URL

The issue is the Alias is being html encoded and not rendered by the OMM engine You need to create a support ticket and request SmartUrlEncoding be enabled for the account to use ampscript in the ...
EazyE's user avatar
  • 8,447
4 votes

How does Guide Template Language parse a straight JSON array?

Short answer is that it should, but it doesn't. I am going off assumptions as I have no definitive proof, but even attempting to use the example in the official docs does not work. <ul class="...
Gortonington's user avatar
  • 30.5k
4 votes

How to access nested JSON (sub-objects) in data

As part of the January 2016 release SFMC added a "nested" datasource type that can be used to extract nested data objects as you have done here with SSJS. The syntax is a little clunky as it requires ...
jnoall's user avatar
  • 156
4 votes
Accepted

Idea: Improve dynamic content blocks (VAWP-related)

I'm not sure why Salesforce Support would have directed you to get votes on your idea on StackExchange. I think they were referring to IdeaExchange. If your Idea reaches 2,500 points (or 250 votes) ...
Eliot Harper's user avatar
  • 16.4k
3 votes
Accepted

Getting Error while try to get Salesforce OAuth access token from SFMC cloudpages ssjs httppost?

To start with: clientId should be client_id clientSecret should be client_secret I would use form-data to post the payload (I've only got this request to work using form-data). Note, the other ...
Eliot Harper's user avatar
  • 16.4k
3 votes

Can you parse custom JSON data using GTL/AmpScript?

Assuming your Sendable DE has a field named 'custom_data' which contains the following value for a Subscriber: {"test" : "abcd", "some_key" : "another_value"} Then you could use the following code ...
Eliot Harper's user avatar
  • 16.4k
3 votes

Guide Template Language to provide dynamic links via href attribute

It is possible to use the Guide Template Language to provide a dynamic link to an href attribute by placing the GTL tag inside of the AMPscript TreatAsContent() function. If you inline the AMPscript ...
jnoall's user avatar
  • 156
3 votes
Accepted

First "0" is missing when displaying a number starting with "0", with GTL

If you use the formatnumber function you can keep the leading zero: {{=formatnumber(TrackingNumber, "d6")}} here is the doc for using Ampscript within GTL
EazyE's user avatar
  • 8,447
3 votes
Accepted

Continuous Pull in Ampscript, GTL, or SSJS from a JSON file

It is not technically possible to replace/update text content in an email after it has been sent. The examples shown e.g. here: How to refer Javascript cloud page in my email in content builder? and ...
Lukas Lunow's user avatar
  • 21.1k
3 votes
Accepted

Storing JSON API payload in triggered send data extension field

There are may be better ways to achieve your requirement, this is how I would tackle. Key Challenges and solution Fields which needs to store JSON require more than 4000 chars which you can overcome ...
Vishal Kumar C V's user avatar
3 votes
Accepted

How can I count the number of objects in my JSON

This is actually super simple, if you use SSJS and the ParseJSON function. The function returns a JS object, and you can easily check it's length property using .length as illustrated below: %%[ VAR @...
Lukas Lunow's user avatar
  • 21.1k
2 votes

Define a function in Guide Template Language

Guide Template Language is able to use AMPscript functions using simple tags and the = prefix. Guide will pass any parameters included in the inner text of the template to the specified function. Once ...
David Teter's user avatar
2 votes

Can AMPScript parse JSON?

In the Marketing Cloud Summer '23 release, there is a new function named BuildRowsetFromJson(1,2,3). It works very similar to BuildRowsetFromXml. Parameter 1 - Source string Parameter 2 - JSON Path ...
Logan B.'s user avatar
  • 146
2 votes
Accepted

Mustache tag containing space characters are not displayed in Guide Template Language

Tag names containing space characters need to be escaped in brackets. For example: {{[Order Sub Total]}}. I thought I tried this previously, but this is working now.
Eliot Harper's user avatar
  • 16.4k
2 votes
Accepted

Cannot set data type for variables in Guide Template language

I've received a response from Salesforce (actually the GTL engineering team) who acknowledge that GTL data types are currently not functioning. This should be resolved in a future release. In the ...
Eliot Harper's user avatar
  • 16.4k
2 votes
Accepted

How to access sub item in json using Guide template language in this code?

I would use datasource instead of dataobject in the example you provided. Simply replace the four occurrences of dataobject with datasource, then move your two closing {{/datasource}} tags after the ...
Eliot Harper's user avatar
  • 16.4k
2 votes

Looping through json in email - impossible?

You can use ServerSide Javascript in emails. Place this code at the top of the page. This code will loop through the JSON and create (and set) the variables to be available in Ampscript. <script ...
Wesley's user avatar
  • 96
2 votes
Accepted

Unable to parse JSON using Guide Template Language

When I use your code, I see that the order appears correctly. I suspect the issue that you are experiencing is related to your XML, as you are using unsupported HTML elements: Content fig graphic ...
Eliot Harper's user avatar
  • 16.4k
2 votes

How to express the last iteration of #each in Guide Template Language?

If you parse the JSON using SSJS, you can use the .length function to determine if you are at the end of a JSON object and accomplish what you are trying to do in your example. I don't believe GTL ...
Spencer Curtis's user avatar
2 votes

Using Journey Context data in email

This is a little crazy and I haven't tested it in the context of a Journey, but it should work. There isn't any journey context data on the list of available personalization strings (https://help....
ncv's user avatar
  • 418
2 votes

GTL Basic Personalization example

You need to assign your JSON data within your field to a variable first, Once you have done that, you then need to target that variable within your GTL like so to obtain each value from each property ...
thechrishaddad's user avatar
2 votes
Accepted

AMPScript/GTL function to check if variable is string or a numeric

I think you can also accomplish your use case with format() as opposed to formatnumber() I believe this fits your use case %%[ set @tn1 = '012345' set @tn2 = '01234a' set @tn3 = '123456' ]%% %%=...
EazyE's user avatar
  • 8,447
2 votes

GTL in a HTML Email

The issue here is not really GTL, but the way you have structured your JSON data. This data structure, in its current form, isn't really suitable for GTL, or any template engine for that matter. It'...
Eliot Harper's user avatar
  • 16.4k
2 votes
Accepted

Parse nested JSON using GTL in CloudPage

I was able to solve your issue as there were some key syntax errors and missing syntax. Also, pardon my noob GTL code as it has become bit rusty over time. Moreover, for reference purpose, I have ...
Brad Sapkota - altus.digital's user avatar

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