0

I'm trying to upsert a DE on my Cloudpage and have no idea where my mistakes are being made

My Cloudpage is something like this:

<script runat="server"> 
Platform.Load("Core","1.1.1"); 
try{ 
</script>
%%[
    Var @LinkParameter, @SubscriberKey, @CurrentClicks, @UpdateClicks, @ActualLink
    Set @SubscriberKey = _subscriberkey
    Set @LinkParameter = QueryParameter("Parameter")

    If @LinkParameter == "Collectors" THEN
        Set @CurrentClicks = Lookup("My DE - test", "Collectors", "CustomerID", @SubscriberKey)
        Set @UpdateClicks = Add(@CurrentClicks, 1)
        UpsertData("My DE - test", 1, "CustomerID", @SubscriberKey, "Collectors", @UpdateClicks)
        Set @ActualLink = "https://wwww.google.com"
        Redirect(@ActualLink)
    Endif
]%%
<script runat="server"> 
}catch(e){  
Write(Stringify(e)); 
} 
</script>

My DE: CustomerID relates to Subscribers on Subscriber Key
enter image description here

My Email content has this line: (1072 is the ID of the Cloudpage)

<a href="%%=CloudPagesURL(1072, 'Parameter', 'Collectors')=%%" title="" alias="" conversion="true" data-linkto="https://">Click my LINK</a>

ANd here is the result I got from try catch SSJS
{"message":"An error occurred when attempting to evaluate an Add function call. See inner exception for details.","description":"ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate an Add function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.InvalidFunctionParameterException: Invalid value specified for function parameter.\r\n Function Name: add\r\n Parameter Name: Value1\r\n Parameter Ordinal: 1\r\n Parameter Type: Numeric\r\n Submitted Value: \r\n ClientID: 100004194\r\n JobID: 0\r\n ListID: 0\r\n BatchID: 0\r\n SubcriberID: 0\r\n Data Source Type: List\r\n Error Code: OMM_INVALID_FUNCT_PARAM\r\n - from OMMCommon\r\n\r\n\r\n\r\n"}

2

You need to add a check before your add function call, to see if @CurrentClicks has a value. If a null value is passed, the add function will not evaluate. You need to change your code to something like this below:

if(NOT EMPTY(@CurrentClicks)) then  
Set @UpdateClicks = Add(@CurrentClicks, 1)
endif

The _subscriberkey works in email. To pass subscriber key for use in the cloud page, you need to pass it in the url and then fetch it using request parameter

4
  • It's not true. The attribute ("Collectors") has default value equals 0 and nullable is unchecked
    – duyduc27
    Dec 7 '20 at 9:39
  • Yes, that is correct, but you are doing a lookup based on subscriber key, if there is no record for your subscriber in the DE, then @CurrentClicks will return null value. Dec 7 '20 at 9:41
  • Thanks. That's what I have thought. I couldn't retrieve _subscriberkey at that moment but now it seems okay (maybe server went error). How to identify a contact on Cloudpage without using "_subscriberkey "? Do you have any idea how to do it?
    – duyduc27
    Dec 7 '20 at 9:59
  • I edited my answer above :) Dec 7 '20 at 10:40

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.