0

I am trying to debug an AMPscript on my cloud page that is throwing a 500 error when I try to preview it. As Cloud Pages do not give any information on the error, I am besides myself as I cant seem to find it.

Here is my code:

        <script runat="server" language="AMPscript">
        var @VariableSummit, @Exposed, @ForeverYoung, @Rustlers , @Jeanology,
     @ExposedC, @ForeverYoungC, @RustlersC , @JeanologyC ,@UTCResubscribeDate
, @UTCTime, @SubscriberDetailRow,@receiveemails
    , @receiveemailsC, @formattedDate,,@mu_sub, @mu_subkey
, @mu_statusCode, @mu_statusMsg, @errorCode,@currentSystemTime,@Previousreceiveemails,@SubscriberKey
        
        
        /*SET @VariableSubmit = RequestParameter("VariableSubmit") */
        /*SET @UTCTimeReSubscribedDate = "NullValue"*/
        SET @SubscriberKey = RequestParameter("Subscriber Key")  
             
            /*Checking the MasterSubcriberDE for their preferences and prefilling it */
        SET @SubscriberDetailRow = LookUpRows("MasterSubscriberDE","Subscriber Key",@SubscriberKey)
        IF ROWCOUNT(@SusbcriberDetailRow)<=0 THEN ENDIF 
        IF ROWCOUNT(@SusbcriberDetailRow)>0 THEN 
          SET @Exposed=Field(ROW(@SubscriberDetailRow,1),"Pref_Exposed")
           IF(LOWERCASE(@Exposed)=="true") THEN set @ExposedC="checked" ELSE SET @ExposedC="" ENDIF
          SET @ForeverYoung=Field(ROW(@SubscriberDetailRow,1),"Pref_ForverYoung")
           IF(LOWERCASE(@ForeverYoung)=="true") THEN set @ForeverYoungC="checked" ELSE SET @ForeverYoungC="" ENDIF
           SET @Rustlers=Field(ROW(@SubscriberDetailRow,1),"Pref_Rustlers")
           IF(LOWERCASE(@Rustlers)=="true") THEN set @RustlersC="checked" ELSE SET @RustlersC="" ENDIF
            SET @Jeanology=Field(ROW(@SubscriberDetailRow,1),"Pref_Jeanology")
           IF(LOWERCASE(@Jeanology)=="true") THEN set @JeanologyC="checked" ELSE SET @JeanologyC="" ENDIF
            SET @receiveemails=Field(ROW(@SubscriberDetailRow,1), "PersonHasOptedOutOfEmail")
            IF(LOWERCASE(@receiveemails)=="false") THEN SET @receiveemailsC="checked" ELSE SET @receiveemailsC="" ENDIF
         ENDIF
      
    
     </script>

I am checking a data extension to see if a customer exists then passing these on to check boxes. I appreciate any guidance on this.

1 Answer 1

3

You've got some extra commas in your variable declarations. You might take a little time to indent your code. It'll make finding this kind of thing a lot easier.

Here's my preferred way to handle checkbox defaulting

<script runat="server" language="ampscript">

    SET @SubscriberKey = RequestParameter("Subscriber Key") 
    SET @rows = LookUpRows("MasterSubscriberDE", "Subscriber Key", @SubscriberKey)

    set @Exposed = "" 
    SET @ForeverYoung = "" 
    SET @Rustlers = ""
    SET @Jeanology = ""
    SET @receiveemails = ""   

    IF rowcount(@SusbcriberDetailRow) > 0 THEN 

      set @row = row(@rows, 1)
      SET @Exposed = Field(@row, "Pref_Exposed")
      SET @ForeverYoung = Field(@row, "Pref_ForverYoung")
      SET @Rustlers = Field(@row, "Pref_Rustlers")
      SET @Jeanology = Field(@row, "Pref_Jeanology")
      SET @receiveemails = Field(@row, "PersonHasOptedOutOfEmail")

    ENDIF 
    

</script>

<br><input type="checkbox" %%=iif(empty(@exposed),"","checked='checked'")=%%> Exposed
<br><input type="checkbox" %%=iif(empty(@ForeverYoung),"","checked='checked'")=%%> Forever Young
<br><input type="checkbox" %%=iif(empty(@Rustlers),"","checked='checked'")=%%> Rustlers
<br><input type="checkbox" %%=iif(empty(@Jeanology),"","checked='checked'")=%%> Jeanology
<br><input type="checkbox" %%=iif(empty(@receiveemails),"","checked='checked'")=%%> Receive emails
7
  • Thanks for this Adam. It's still throwing a 500. It says to wait for 5 minutes but I have usually found changes to be immediate.
    – 0xsegfault
    May 21, 2017 at 21:01
  • Data_Kid, I would recommend changing your RequestParameter functions with hard coded values, then pasting the code in an HTML paste email and previewing the email to get a more helpful error. Also, use AMPscript code blocks like Adam is using, as script tags won't show the error detail when previewing an email. May 21, 2017 at 21:03
  • Thanks will give it a go. Re: Script tag. It's a Cloud Page..will the tags Adam is using help show the errors?
    – 0xsegfault
    May 21, 2017 at 21:05
  • Is it because on rendering, the first condition, IF ROWCOUNT(@SusbcriberDetailRow) <= 0 THEN ENDIF is true and I havnt provided default variables for scenario?
    – 0xsegfault
    May 21, 2017 at 21:16
  • Updated my answer with a better example. May 22, 2017 at 2:35

You must log in to answer this question.

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