0

In the code below I'm not getting into the second If statement even when the @sfid (passed in from the url) variable starts with 00Q. When the page is loaded I can see the two outputs that have 00Q for @Startswith, but always Contact for @leadString.

Where have I made what must be a simple mistake?

    %%[
  if @rowCount < 1 then

     SET @Startswith = Substring(@sfid, 1, 3) 

        If @Startswith(@sfid, 1, 3)=='00Q' then
            set @leadString = "Lead"

            else
        set @leadString = "Contact"

        endif
    output(concat("Startswith is: ", @Startswith))
    output(concat("leadString is: ", @leadString))

        UpdateSingleSalesforceObject(@leadString, @sfid,
        "Double_opt_in_date__c", Format(DateParse(now(),1), "yyyy-MM-ddTHH:mm:ss.000"),
        "Double_opt_in__c", "True")


  endif]%%  
  • this line seems wrong @Startswith(@sfid, 1, 3)=='00Q' then should possibly be @Startswith=='00Q' then – EazyE Dec 3 '19 at 21:43
1

You have a syntax error on the following line:

If @Startswith(@sfid, 1, 3)=='00Q' then

It should be:

If @Startswith =='00Q' then

Refer to the AMPScript Language Elements for an understanding on how the language operates.

Try this:

%%[

if @rowCount < 1 then

 set @Startswith = Substring(@sfid, 1, 3) 

    if @Startswith == '00Q' then
      set @leadString = "Lead"
    else
      set @leadString = "Contact"
    endif

    output(concat("Startswith is: ", @Startswith))
    output(concat("leadString is: ", @leadString))

    UpdateSingleSalesforceObject(@leadString, @sfid,
      "Double_opt_in_date__c", Format(DateParse(now(),1), "yyyy-MM-ddTHH:mm:ss.000"),
      "Double_opt_in__c", "True")
endif
]%%
  • That was it, thank you. I guess I had stared at it too long. – Ben Patterson Dec 4 '19 at 15:17

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.