Questions tagged [ampscript]

AMPscript is a proprietary scripting language for Salesforce Marketing Cloud products that you can embed within HTML emails, text emails, landing pages and SMS messages to control the content that is displayed to the individual consumer. It also provides functionality to track impressions and highlight which content areas get the most attention from the viewer.

Filter by
Sorted by
Tagged with
4 votes
1 answer
66 views

Marketing Cloud : Text Response works for the first time while issuing error messages afterwards

From MobileConnect, I have initiated a SMS send and a text response for the same. Both are working fine. I am able to send a text response which gets handled by my AMPscript shown below. %%[ var @...
Endless's user avatar
  • 65
1 vote
1 answer
95 views

Get complete URL with parameters in SSJS/Ampscript

Here's how to get the URL of current page (with parameters) in SSJS: var url = Platform.Request.RequestURL(); Effectively, it's the equivalent of RequestParameter('PAGEURL') in AMPscript. However, ...
Lukas Lunow's user avatar
  • 20.5k
2 votes
1 answer
68 views

Marketing Cloud : CreateSalesforceObject not working

We have a custom object Marketing_Cloud_Response__c in Salesforce. This object has a lookup to our Employee__c (custom object) record. I have written the following AMPscript in Text Response ...
Endless's user avatar
  • 65
0 votes
0 answers
21 views

In GTL datasource can I have conditional content appear based on the first instance only?

I'm using Amspscript and GTL datasource to extract information from a field in a data extension called: cancelled. This field has multiple items in there and within cancelled there is another field ...
T01's user avatar
  • 9
0 votes
1 answer
39 views

AMPScript Lookup row function

Can we use lookuprows() function of AMPScript like this? LookupRows(@ContactDE,'id',@SubscriberKey) I have seen this code in the one of the email but I am not getting it instead of DE name why they ...
Adam Coder's user avatar
0 votes
1 answer
42 views

How to create an alert when blank AMPScript data and cancel send

I'm new-ish to AMPScript. In our Marketing Cloud instance we have AMPScript used in various journeys, some of these are sourcing Data Extension content, others are trigger based and pulling directly ...
Maddisonpayne123's user avatar
0 votes
3 answers
81 views

How to assign multiple coupons at the time of email sending

Use Case: I have a data extension with a list of available coupons and a second data extension that contains an email address and how many coupons can be assigned to each email address. Current code ...
user47606's user avatar
0 votes
0 answers
74 views

Marketing Cloud Ampscript add and group by fields

Looking to add the Cost here and grouped by OrderId and purchaseNumber. I have the below but I think it is incorrect. I have other fields in the Data Extension but want the sum of cost aggregated by ...
Stewie's user avatar
  • 1
0 votes
0 answers
51 views

Getting Error on Subscriber Preview with AMPScript Code in the email

I am getting an error on the subscriber preview section after testing the AMPScript with test DE records in Marketing Cloud. Below is my code: %%[ set @Phone = [Phone] set @Name = [First Name] ...
Adam Coder's user avatar
0 votes
0 answers
37 views

Using Content Block of type Layout in a custom HTML template for SFMC

I am working on an email template that uses content blocks. The content blocks are retrieve using some ampscript that loops through a JSON string of contentBlocksIDs. I also wanted to use content ...
Ahmed's user avatar
  • 11
-2 votes
1 answer
38 views

Getting Error on Fetching Data from two different DE into Email Template in SFMC

I am trying to get the data from two different Data extensions DE A has columns fname, Lname, Contact ID, Email, Phone, Account ID and DE B which is Salesforce object DE has Account ID, Owner ID, ...
Adam Coder's user avatar
0 votes
0 answers
64 views

Hash Url in ampscript

I have a cloudpage where this page redirect from company's marketing site with using an email as variable. I write a code in JavaScript code where it redirect to cloudpage url with email where email ...
omor faruk's user avatar
0 votes
1 answer
49 views

How can I query a new Account record straight away and retrieve PersonContactId in a SFMC Cloud Page?

I have a sign up form that upon submission will create a PersonAccount (Account) record in Salesforce. I then want to create the corresponding Contact in SFMC so that we have the values until it syncs ...
Chris Hughes's user avatar
0 votes
1 answer
54 views

Ampscript condition IF with OR

I inserted the following Ampscript %%[IF (@Color != "Red" OR @Color != "White") THEN]%% HTML %%[ENDIF]%% The aim is to show a button (HTML) when the field Color is different ...
Maria's user avatar
  • 1
0 votes
0 answers
41 views

InsertData ampscript function not working on SMS and cloud Pages

I am trying to use InsertData amp-script function in an SMS. But its not working. My ultimate objective is to update customer data into master data extension when someone subscribes to 'START' ...
Abhra Chowdhury's user avatar
0 votes
1 answer
69 views

dynamic button link on mobile and desktop

I need to add some code so when I send an email on desktop to have a different link www.desktop.com under a button and to have a different link on mobile www.mobile.com . I've tried to use media ...
Duicug's user avatar
  • 457
0 votes
0 answers
51 views

Dynamic UTMs to Track Customer Buying Behavior

I'm currently facing a challenge with our email marketing campaign at SFMC. We want to send a promotional email to customers who have bought a specific item. The problem is that we don't yet have ...
Mik's user avatar
  • 3
0 votes
1 answer
48 views

Remove plus sign from phone number using ampscript

I am trying to remove a + from a phone number field. The field name is referenced below as "MessagingPlatformKey" I am collecting a response via SMS and feeding the then matching that user ...
Eric Wooster's user avatar
0 votes
1 answer
49 views

Is there a way to send one email to a contact that has multiple entries in a Marketing Cloud Journey?

I believe the answer is no but I'd like to see if maybe there is something I've overlooked. We have a custom object in Salesforce that we use to track training completions and expiration dates. We'd ...
antmast's user avatar
0 votes
0 answers
29 views

View in browser content in alternate language

We have emails that have the view in browser -- <a alias="View-In-Browser" href="%%view_email_url%%" style="text-decoration:none; color:#0072CE;" target="_blank&...
tfigmkz's user avatar
0 votes
0 answers
29 views

I have a cloudpage and using InsertDE function, however it seems that it only working at one submission [duplicate]

I have a cloudpage and using InsertDE function, however it seems that it only working at first submission For example: Scenario 1: I fill up the form using a new data extension without data and then ...
Rain's user avatar
  • 1
0 votes
1 answer
46 views

I cannot insert to specific Data Extension Amp script

I have a cloudpage that is having a form and when I click submit it should have my details saved on the data extension and proceed to the confirmation page set @prospectsDE = 'Prospects' /* ...
Rain's user avatar
  • 1
0 votes
0 answers
28 views

AMPscript error while testing saying I haven't ended an IF while looping IFs inside a FOR

Hey guys I'm developing a code where I need to loop 2 IFs inside a for but I'm getting an error saying I'm not closing my IFs.... although I have quadruple checked and I'm definitely closing my IFS, ...
Guilherme Santos's user avatar
0 votes
1 answer
47 views

AMPscript concat while setting variable

I'm facing an issue where I'm not sure if this would be the correct way to define my var. Here's the code : %%[var @product1, @product2, @product3, @product4, @product5, @product6, @marca, @rows, @...
Guilherme Santos's user avatar
0 votes
1 answer
52 views

Utilizing journey data in AMPscript

This is a simple question but I simply can't find an answer anywhere. I have a journey that is currently using a Data extension that is updated daily from an automation, and in AMPscript I need to use ...
Guilherme Santos's user avatar
0 votes
1 answer
56 views

Get Business Unit Ids to be used in Custom Activity for Marketing Cloud

we have developed a custom activity to integrate Twilio in Marketing Cloud, it is working fine connecting Marketing Cloud to the Twillio account and sending SMS to the contacts in the source Data ...
David Boada's user avatar
1 vote
0 answers
95 views

How to target a specific device in case a user has multiple devices (Push Notification)

I need to understand how to target a specific device in case a user has multiple devices via a push notification activity (journey builder). I found this official SF article Link Where they mention: &...
Juraj Reško's user avatar
0 votes
1 answer
31 views

Ampscript variables showing up in send previews & test sends but not prod sends

I have a subject line that takes a bonus offer, adds it to the current balance, then displays the sum. Everything worked in testing, everything previewed right when viewing in Send Wizard when using ...
PForsyth's user avatar
0 votes
1 answer
66 views

validate cloudpage data

I'm very much stuck on how to approach this, so any guidance would be greatly appreciated! Background A client wants to build a simple cloudpage from which entities will fill in their details, and ...
JordanSFMC's user avatar
0 votes
1 answer
49 views

Salesforce Marketing Cloud SSJS: Unable to fetch the HttpRequest response

I am using the below SSJS code. var req = new Script.Util.HttpRequest(eventEndPoint); req.emptyContentHandling = 0; req.retries = 2; req.continueOnError = true; //req....
Ranjan's user avatar
  • 67
0 votes
0 answers
58 views

Issue with adding / updating a record into a data extension via cloud page

I am trying to add / update a test record in a data extension from a cloud page but I keep getting 500 - Internal server error I have looked at the online resources and some answers here as well ...
kl2's user avatar
  • 317
0 votes
1 answer
76 views

How to Update Salesforce Custom Object through AmpScript in Marketing Cloud

We have an Email that has a CTA Button and upon clicking the CTA Button the response should be captured in MC and a field in Salesforce Custom Object should get updated. My code is working fine in ...
Reva's user avatar
  • 3
0 votes
1 answer
43 views

UTM solution for Dynamic Email

We have a dynamic email template where we populate content via AMPscript from a Data Extension for different locales. I'd like to enable Web Analytics Connector for our account however I'm not quite ...
DBK's user avatar
  • 1
0 votes
1 answer
95 views

Recommended approach for coupon assignment in SFMC?

In SFMC, we are currently using claimrow() approach for coupon assignment but in past we have seen some issues with this where same coupons getting assigned to same subscribers since coupon email is ...
kl2's user avatar
  • 317
0 votes
1 answer
153 views

How to create dynamic email templates in SFMC

Currently, our emails are using content blocks where shared areas like header and footer are called in an email file. The reason we use content blocks is because if anything changes in these content ...
kl2's user avatar
  • 317
0 votes
1 answer
70 views

Unable to Update Existing DE with Ampscript

We have a Registration Form with Fields FirstName Email Phone Job Function Status When someone enters details on the form and clicks on submit the data is stored in MC and creates a Lead in CRM.We ...
Reva's user avatar
  • 3
0 votes
0 answers
105 views

How to check if a today's date is between two dates using AMPScript in SFMC?

Background: On a cloud page in SFMC, I am trying to display a message if today's date is between start and end dates that are coming from data extension. Question: How can I perform a check and see if ...
kl2's user avatar
  • 317
0 votes
1 answer
43 views

help with UpdateSingleSalesforceObject with server-side Javascript script

I want to perform data updates based on data that is in a DE, if the Contact_Id of the case is the same as what is in the DE then perform the modifications that are in the variables but when I run the ...
Henry Cast's user avatar
0 votes
1 answer
45 views

Using the ampscript ClaimRow DE function, cannot populate email address in DE col., in my case I display 2 unique codes or serial numbers per email

[![Data Extension screenshot with 2 columns unique serial numbers[][1]1]2 I am not sure why the Email column is not being populated with the subscriber email address, for the coupon codes/serial ...
Gold's user avatar
  • 57
0 votes
0 answers
34 views

AMPScript in footer not working

Trying to add a content block to the settings footer here: But it doesn't seem to work. I even tried to copy past the code and nothing... Is there a built-in limitation? Here is the way I add the ...
yoni349's user avatar
  • 81
-1 votes
1 answer
45 views

Converting Currency into USD using AMP script is not working

I tried to convert currency into USD, but instead of converting into USD it's moving to decimal place. My code is %%[ Var @num Set @num = formatcurrency("123.45678", "en-Us") ] %% ...
SFMC Developer's user avatar
0 votes
1 answer
69 views

Attachment sent incorrectly

I set up sending an attachment in my email using an amp script. %%[ var @customerKey, @fileAlias set @fileName = "https://drive.google.com/file/d/1234567890/view?usp=sharing" set @fileAlias ...
Slavik's user avatar
  • 25
0 votes
1 answer
56 views

I'm trying to sum all the rows of a single column in a Data extension and then divide that sum by the total rows so I can get the average

This is what I've written so far but I keep getting errors on the summing part. Eventually with this I'll have to sum a bunch of multiple fields and divide because I need to display the averages of ...
Ebrahim Alas's user avatar
0 votes
1 answer
63 views

Append unique id to external survey link in email studio?

We're having trouble appending a unique id within the external survey link in email studio. Right now, we have the html set to a survey button: %%[ Set @surveyButton = concat("[https://m.survey....
AFon's user avatar
  • 1
0 votes
0 answers
115 views

Dynamic Bitly url shorten in SMS SFMC

In sms, I want to add the cloud page URL with the dynamic values. When someone click on the URL it redirects to the landing page and data is inserted into the data extension using the lookup function. ...
Jain's user avatar
  • 1
0 votes
1 answer
62 views

Looping SSJS to output Ampscript variables partially works if I don't use a word building array function. Can't figure out why

I've got a data extension which has multiple rows for each item a user has in their cart and it's tied to their email address. The main issue is I need to cut off the product name at a max character ...
Erik B's user avatar
  • 63
0 votes
1 answer
190 views

How to update a field in an existing data extension using ampscript?

I am trying to add some random numbers to an existing data extension field. When I print the results in CloudPage, I get the results. But when I add a line to update data extension, it is hitting an ...
Dinesh S's user avatar
0 votes
1 answer
68 views

Personalization string using Contact Data (not Journey Data) in Journey Builder Email

I have a birthday journey, where the entry source is a DE from Salesforce that is overwritten every day to include only those who have their birthday coming up 6 weeks from that day. The first email ...
Hannakorfin's user avatar
0 votes
1 answer
55 views

Re-Subscribe contacts who have unsubscribed on contact creation as a result of Journey using salesforce data entry

I have a journey with a SF data as entry source, this journey captures new contacts created in SF using SFMC connector. On Salesforce, when a contact is created, the initial state of emailoptout is ...
Boody29znexus's user avatar
0 votes
1 answer
73 views

Can you pass encoded url parameter strings in a cloudpages url?

This may not be an SFMC problem at all, and more of a scripting issue. But I wanted to see if there was anything I could do from an SFMC side. I'm using the below code to generate an event on a ...
en-rep's user avatar
  • 25

1
2 3 4 5
65