sfmc // CloudPagesPROJECT

CloudPage Upsert Instead of Blind Insert

Use a stable key so refresh/retry does not blindly append duplicate state rows.

cloudpagesupsertdataidempotencydata extension
Context Pack →Open Workspace →
Trust & provenancePROJECT
Evidence tierPROJECTOfficial sources1Other sources0Last verified2026-10-05

Evidence tier describes my hands-on relationship with the content. Official sources describe platform contracts/documentation. Production observations should not automatically be treated as official limits.

EvidencePROJECT
Difficultyintermediate
Verified2026-10-05
Use when

A preference/action page may be submitted more than once.

%%[
VAR @subscriberKey, @choice
SET @subscriberKey = RequestParameter("subscriberKey")
SET @choice = RequestParameter("choice")

IF NOT Empty(@subscriberKey) AND NOT Empty(@choice) THEN
  UpsertData(
    "Preference_State",
    1,
    "SubscriberKey", @subscriberKey,
    "Choice", @choice,
    "UpdatedAt", Now()
  )
ENDIF
]%%
Why it works

UpsertData updates a matching keyed row or inserts it when absent, making repeated requests safer than blind InsertData for current-state records.

Gotchas

Idempotency depends on choosing the right key and semantics. An audit/history table may intentionally insert a new event instead.

Sources / verification