Runtime verified Test scripts included

Syntax

InsertDE(dataExt, columnName1, valueToInsert1[, columnNameN, valueToInsertN, ...])  →  string

Parameters

Name Type Required Description
dataExt string Yes Name or external key of the data extension to insert into
columnName1 string Yes First column to write
valueToInsert1 string | number Yes Value for the first column
columnNameN string No Further columns, each paired with a value
valueToInsertN string | number No Value for the corresponding further column

Example

%%[
  InsertDE("AMP_VERIFY_SCRATCH", "Id", "D1", "FirstName", "Dora", "Score", 3)
]%%

Renders nothing — InsertDE returns an empty string. Reading the row back in a later render confirms the write: rows=[1] FirstName=[Dora].

A realistic use inserts a row inside a send:

%%[
  InsertDE("SendLog", "SubscriberKey", _subscriberkey, "SentAt", Now())
]%%

Return value

string — always an empty string, so nothing is emitted into the message. This is the only runtime difference from InsertData, which returns the inserted-row count. The *DE family is intended for email sends where you do not want a stray value printed; the *Data family is intended for CloudPages.

Behaviour

Ordered column/value pairs. Arguments after dataExt are read as column, value, column, value, … — identical to InsertData. The families differ only in the return value, not the argument shape.

Inserting a duplicate primary key aborts the page. A second insert with the same PK raises a runtime error that discards all output — guard with a prior Lookup or use UpsertDE.

Writes are not visible to same-render reads of a row already read. AMPscript caches data-extension row reads within a single render; confirm the insert in a subsequent render.

Show test script
%%[
  VAR @b, @r
  SET @b = RequestParameter("b")

  IF @b == "zzz" THEN
    OutputLine(Concat("CTRL=[alive]"))
  ENDIF

  IF @b == "safe" THEN
    DeleteData("AMP_VERIFY_SCRATCH", "Id", "D1")
    SET @r = InsertDE("AMP_VERIFY_SCRATCH", "Id", "D1", "FirstName", "Dora", "Score", 3)
    OutputLine(Concat("InsertDE ret=[", @r, "]"))
  ENDIF

  IF @b == "read" THEN
    OutputLine(Concat("D1 rows=[", RowCount(LookupRows("AMP_VERIFY_SCRATCH", "Id", "D1")), "] FirstName=[", Lookup("AMP_VERIFY_SCRATCH", "FirstName", "Id", "D1"), "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next No

See also