InsertData

Inserts rows into a data extension, and returns the number of rows inserted.

Use this function in CloudPages, landing pages, microsites, and SMS messages in Mobile Connect. Use the InsertDE() function to insert rows into a data extension from emails.

The InsertData() function has three parameters.

  • dataExt (string): Required. The name of the data extension that you want to insert a row into.
  • columnNames[] (array): Required. An array that contains the names of the columns to populate with data in the new row.
  • values[] (array): Required. An array that contains the values to insert into the columns specified in the columnNames array.

To insert data into a data extension, specify the data extension that you want to insert a row into. Next, specify the columns that you want to populate with data in the new row. Finally, specify the values for those columns. Make sure that the values in the second array align with the columns in the first array.

If there’s an issue inserting the record, the function returns a 500 error. This error can occur when a required column isn’t included in the request, or if you pass a duplicate value for a primary key. To ensure that your content loads as expected, use a try/catch block. If you want to update existing content or insert new data, consider using the UpsertData() function instead.