0

I have built a preference center but need to tweek this block of code to return nothing if "ALL STORES" is selected, or the selected option if not "ALL STORES".

I am sure its this block thats making it return a 500 error on submission.

IF (RequestParameter("SelectPreferredStore")= 'ALL STORES') THEN
  SET @PreferredStore = ""
  SET @PreferredStoreC = ""
ELSE
  SET @PreferredStore=RequestParameter("SelectPreferredStore")
  SET @PreferredStoreC=@PreferredStore
ENDIF

What am I doing wrong? Will really appreciate guidance. Please note the block is within a bigger Ampscript block that I am sure is fine

1 Answer 1

0

Without seeing the full page, i would reckon you need a script like this;

SET @PreferredStore = RequestParameter(SelectPreferredStore)

IF @PreferredStore == "ALL STORES" THEN
SET @PreferredStore = ""
SET @PreferredStoreC = ""
ELSE
SET @PreferredStore = @PreferredStore
SET @PreferredStoreC = @PreferredStore
ENDIF

Though I'm not sure what your use case for both variables are, as it seems to be much the same? (do you need the preferredstoreC?

3
  • 2
    "=" in AMPScript is used as an assignment operator - it sets the value of a variable. The comparison operator is "==" - @Data_Kid should have been using this to evaluate the query string param in his IF statement.
    – Macca
    Commented Feb 7, 2017 at 7:15
  • Indeed. Wasn't aware that you could use requestparameter directly like that though, i'm always setting a variable and then based on that variable creating my logic. Personally, feel it makes for cleaner code - but good to know the other stuff works as well! :) Commented Feb 7, 2017 at 9:14
  • I'd write my AMPScript as you have there and your answer isn't wrong at all. It is clearer. My point was mare Data_Kid's principal issue was the confusion around the use of single and double equals operators.
    – Macca
    Commented Feb 7, 2017 at 9:21

You must log in to answer this question.

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