1

I'm trying to set a variable dynamically to UpsertData function via Cloud Page form submission, but haven't been able to get it working so far.

The attribute name from Data Extension is the dynamic value here, to which I would be posting a static value.

%%[ VAR @skey, @Type
SET @skey = RequestParameter("skey")
SET @Type = RequestParameter("Type")

IF Not Empty(@skey) THEN
UpsertData("MyDataExtension", 1,
"ID", @skey,
"@Type", "Accepted"
)
ENDIF]%%

I've tried setting the Data Extension attribute name in various ways, but no dice so far.

Examples that don't work :

"%%=v(@Type)=%%", "Accepted"

And

"TreatAsContent(%%=v(@Type)=%%)", "Accepted"

Has anyone worked with a similar scenario or knows if this is even possible?

5

You need to output the value using the v-Function in order to achieve that. As you are already within an AMPscript-Block, you don't need the starting and ending codes %%= and =%%. This code will work:

%%[
    VAR @skey, @Type
    SET @skey = RequestParameter("skey")
    SET @Type = RequestParameter("Type")

    IF Not Empty(@skey) THEN
        UpsertData("MyDataExtension", 1, "ID", @skey, v(@Type), "Accepted")
    ENDIF
]%%
  • Thank you very much. After four hours of trying everything .. it was that simple. Much appreciated! – Rain Feb 6 at 15:39
  • 1
    You are welcome, glad I could help! ;) – Markus Slabina Feb 7 at 7:39

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.