0

I'm aiming to have Ampscript on a Cloudpage decrement a value in a specific data extension field whenever the page loads. Eventually there will be further logic to determine which of two values to change, but as a proof-of-concept/test I'm just trying to reduce both. Currently my test page is throwing an internal server error and fails to load. The full code is below:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>
placeholder
</p>
</body>
%%[
Var @ontrade, @email, @otdec, @emdec, @update1, @update2

Set @ontrade = Lookup('GB_Test_Kit_Count', 'Count', 'Type', 'ontrade')
Set @email = Lookup('GB_Test_Kit_Count', 'Count', 'Type', 'email')
Set @otdec = Add(@ontrade,-1)
Set @emdec = Add(@email,-1)

Set @update1 = UpdateData(
'GB_Test_Kit_Count',
1,
'Type',
'ontrade',
'Count',
@otdec
)

Set @update2 = UpdateData(
'GB_Test_Kit_Count',
1,
'Type',
'email',
'Count',
@emdec
)
]%%
</html>

The data extension is named GB_Test_Kit_Count. It has two columns, 'Type' and 'Count' and two records {ontrade, 50} and {email, 100}.

I'm guessing I've just screwed up the syntax somewhere, but I can't spot the problem.

1

The problematic part is:

Set @otdec = @ontrade-1
Set @emdec = @email-1

You can use Subtract or Add like:

Set @otdec = Add(@ontrade,-1)
Set @emdec = Add(@email,-1)

The documentation:

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/Add.htm

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/Subtract.htm

8
  • Made that change, but I'm still getting the same error. Jan 17 '19 at 9:38
  • Are you doing it on the same page or on a new page? In other words, do you see "placeholder" text when you preview the page before publishing? Jan 17 '19 at 9:40
  • The preview doesn't render at all. It's just a grey screen with an endless loading icon. Jan 17 '19 at 9:42
  • It works on my end, the only possible solution that I think is trying the code in a new page because when you are working on the same page, because of cache issues, you still see the error. Jan 17 '19 at 9:44
  • Even when I copy the code to a new page it doesn't work. I thought it might be because the capitalization was different on the column names between the DE and the code, but I fixed that and it hasn't helped. Jan 17 '19 at 14:11

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.