Say you need to find the lowest of three numbers in an email — numbers you’ve retrieved from a Data Extension. Here’s one way to do it in AMPScript with a set of inline-if statements:
Suppose you want to see if a Subscribers exists on a List in a Landing Page or Microsite Page in the Salesforce Marketing Cloud? I generally do that with SSJS for various reasons. It’s also possible to do it with AMPScript API functions. Bonus that it’s faster:
Do you know about the MicrositeURL() AMPScript function? It’s relatively new. It sure is handy if you’re building custom preference centers in Enterprise 2.0 business units.
The idea is that you can encrypt custom parameters in your email links to Microsite pages and then retrieve the unencrypted values with an AMPScript function. Once you have the business unit MID in the microsite page, you can use it to ensure your API calls are for the correct business unit.
In your email you would have this code:
In the case where the the subscriberMID is not set, default to the parent business unit’s MID, which is accessible from the memberid personalization string.
Did you know you can use regular expressions in AMPScript?
Here are some RegExMatch() snippets that I’ve used:
@s = input string
@p = pattern
@m = match
@o = output
input: whee (whatever it is) whoop
match: (whatever it is)
output: whee whoop
Here is a good way to display a grid of external content in an email without repeating a significant amount of AMPScript. It utilizes an XML string and uses XPATH to retrieve content using the BuildRowSetFromXML() function.
Questions? Comments? Feel free to leave a comment below.