2

I would like to insert new email dresses via survey using ampscript in an existing data extension (TEST_LANDING) where all my contacts are already. I tried with InsertDE and updateData function and it works but only insert email.

Here is my code :

set @newemail= updatedata("TEST_landing",1,"EMAIL", @email) ==> it inserts well an email adress

So I tried with some other data to add :

set @newemail= updatedata("TEST_landing",1,"EMAIL", @email,"COUNTRY_CODE",FR, "LANGUAGE_CODE",fr, "CREATION_DATE",SystemDateToLocalDate(NOW(),"CHANNEL_LEVEL_1",Acquisition)

And it doesn't work.

Moreover does anyone know what is the difference between insertdata, insertDE, updatedata, updateDE, upsertData functions ?

1

All the 'DE' functions are to be used at send time inside of emails only
All the 'Data' functions are to be used in landing pages, script activities, etc.

Insert - Add New record only. If record already exists, it will throw an error.
Update - Update an existing record only. If record does not already exist, it will throw an error.
Upsert - Add and update. This will add a record if it does not exist, or update an existing record.

You also don't need to set it to a variable, you can just use the function by itself, like below:

%%[ 
    updatedata("TEST_landing",1,"EMAIL", @email,"COUNTRY_CODE","FR", "LANGUAGE_CODE","fr", "CREATION_DATE",SystemDateToLocalDate(NOW()),"CHANNEL_LEVEL_1", "Acquisition")
]%%

Please note that I added in quotes:

  • to the FR for COUNTRY_CODE
  • the fr for "LANGUAGE_CODE"
  • Acquisition for "CHANNEL_LEVEL_1"

I also added an end parenthesis for your "CREATION_DATE" function.

This should now function as required. I usually recommend using the UPSERT option, unless you need to restrict it to add only or update only - in which case I would highly recommend having conditional statements around it to prevent this throwing an error.

1

I think the problem is that you are missing the "" and you haven't closed the brackets on the function SystemDateToLocalDate(). Could you try this please :

@newemail= updatedata("TEST_landing",1,"EMAIL", @email,"COUNTRY_CODE","FR", "LANGUAGE_CODE","fr", "CREATION_DATE",SystemDateToLocalDate(NOW()),"CHANNEL_LEVEL_1","Acquisition")

-> Please check the link below to see difference between the ampscript functions https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/upsertdata.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.