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?

1 Answer 1

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
]%%
2
  • Thank you very much. After four hours of trying everything .. it was that simple. Much appreciated!
    – Rain
    Commented Feb 6, 2019 at 15:39
  • 1
    You are welcome, glad I could help! ;) Commented Feb 7, 2019 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .