I'm trying to create the following process: If your country is United states you should see a certain picklist of states, If your country is Canada you should see another certain picklist of states and the same for Mexico.

The front end and form are all working, but now I'm struggling with my

IF RequestParameter("country") == "US" THEN
SET @state = RequestParameter("usa_state")
ELSEIF RequestParameter("country") == "CA" THEN
SET @state = RequestParameter("ca_state") 
ELSEIF RequestParameter("country") == "MX" THEN
SET @state = RequestParameter("mx_state")
ELSE SET @state = ""

usa_state, ca_state and mx_state are the fieldnames and @state is used in the CreateSalesforceObject. All info is coming through fine except for the state information. I'm not getting any errors, but I don't see anything in Sales Cloud.

Any ideas?

-- UPDATE --

These are the dropdowns:


                    <label class="form-field__label" for="country-select">Country*</label>
                    <select name="country" id="country-select" onchange="toggleDropdowns()" required>
                        <option selected disabled hidden>Choose your country...</option>
<option value="US">United States</option>
<option value="CA">Canada</option>
<option value="MX">Mexico</option>


<div id="dropdown-1" class="display--none">
                <label class="form-field__label" for="select">State*</label>
              <p class="form-field__hint">Please select your state</p>
                <select name="usa_state" id="select">
                   <option selected disabled hidden>Select state...</option>
         <option value="AK">Alaska</option>
                    <option value="AL">Alabama</option>
                    <option value="AR">Arkansas</option>
                    <option value="AS">American Samoa</option>
                    <option value="AZ">Arizona</option>
                    <option value="CA">California</option>
                    <option value="CO">Colorado</option>
                    <option value="CT">Connecticut</option>
                    <option value="DC">D.C.</option>
                    <option value="DE">Delaware</option>
                    <option value="FL">Florida</option>
                    <option value="FM">Micronesia</option>
                    <option value="GA">Georgia</option>
                    <option value="GU">Guam</option>
                    <option value="HI">Hawaii</option>
                    <option value="IA">Iowa</option>
                    <option value="ID">Idaho</option>
                    <option value="IL">Illinois</option>
                    <option value="IN">Indiana</option>
                    <option value="KS">Kansas</option>
                    <option value="KY">Kentucky</option>
                    <option value="LA">Louisiana</option>
                    <option value="MA">Massachusetts</option>
                    <option value="MD">Maryland</option>
                    <option value="ME">Maine</option>
                    <option value="MH">Marshall Islands</option>
                    <option value="MI">Michigan</option>
                    <option value="MN">Minnesota</option>
                    <option value="MO">Missouri</option>
                    <option value="MP">Marianas</option>
                    <option value="MS">Mississippi</option>
                    <option value="MT">Montana</option>
                    <option value="NC">North Carolina</option>
                    <option value="ND">North Dakota</option>
                    <option value="NE">Nebraska</option>
                    <option value="NH">New Hampshire</option>
                    <option value="NJ">New Jersey</option>
                    <option value="NM">New Mexico</option>
                    <option value="NV">Nevada</option>
                    <option value="NY">New York</option>
                    <option value="OH">Ohio</option>
                    <option value="OK">Oklahoma</option>
                    <option value="OR">Oregon</option>
                    <option value="PA">Pennsylvania</option>
                    <option value="PR">Puerto Rico</option>
                    <option value="PW">Palau</option>
                    <option value="RI">Rhode Island</option>
                    <option value="SC">South Carolina</option>
                    <option value="SD">South Dakota</option>
                    <option value="TN">Tennessee</option>
                    <option value="TX">Texas</option>
                    <option value="UT">Utah</option>
                    <option value="VA">Virginia</option>
                    <option value="VI">Virgin Islands</option>
                    <option value="VT">Vermont</option>
                    <option value="WA">Washington</option>
                    <option value="WI">Wisconsin</option>
                    <option value="WV">West Virginia</option>
                    <option value="WY">Wyoming</option>
          <div id="dropdown-2" class="display--none">
                <label class="form-field__label" for="select">Province*</label>
              <p class="form-field__hint">Please select your province</p>
                <select name="ca_state" id="select">
                   <option selected disabled hidden>Select province...</option>
                    <option value="AB">Alberta</option>
                    <option value="MB">Manitoba</option>
                    <option value="BC">British Columbia</option>
                    <option value="NB">New Brunswick</option>
                    <option value="NL">Newfoundland and Labrador</option>
                    <option value="NS">Nova Scotia</option>
                    <option value="NT">Northwest Territories</option>
                    <option value="NU">Nunavut</option>
                    <option value="ON">Ontario</option>
                    <option value="PE">Prince Edward Island</option>
                    <option value="QC">Quebec</option>
                    <option value="SK">Saskatchewan</option>
                    <option value="YT">Yukon Territory</option>
          <div id="dropdown-3" class="display--none">
            <label class="form-field__label" for="select">State*</label>
              <p class="form-field__hint">Please select your state</p>
                <select name="mx_state" id="select">
                  <option selected disabled hidden>Select state...</option>
                  <option value="AG">Aguascalientes</option>
                  <option value="BC">Baja California</option>
                  <option value="BS">Baja California Sur</option>
                  <option value="CM">Campeche</option>
                  <option value="CS">Chiapas</option>
                  <option value="CH">Chihuahua</option>
                  <option value="CO">Coahuila</option>
                  <option value="CL">Colima</option>
                  <option value="DF">Ciudad de Mexico</option>
                  <option value="DG">Durango</option>
                  <option value="GT">Guanajuato</option>
                  <option value="GR">Guerrero</option>
                  <option value="HG">Hidalgo</option>
                  <option value="JA">Jalisco</option>
                  <option value="EM">Estado de Mexico</option>
                  <option value="MI">Michoacán</option>
                  <option value="MO">Morelos</option>
                  <option value="NA">Nayarit</option>
                  <option value="NL">Nuevo León</option>
                  <option value="OA">Oaxaca</option>
                  <option value="PU">Puebla</option>
                  <option value="QT">Querétaro</option>
                  <option value="QR">Quintana Roo</option>
                  <option value="SL">San Luis Potosí</option>
                  <option value="SI">Sinaloa</option>
                  <option value="SO">Sonora</option>
                  <option value="TB">Tabasco</option>
                  <option value="TM">Tamaulipas</option>
                  <option value="TL">Tlaxcala</option>
                  <option value="VE">Veracruz</option>
                  <option value="YU">Yucatán</option>
                  <option value="ZA">Zacatecas</option>
  • Are you sure the IF statement isn't simply defaulting to the final "ELSE" and therefore sets @state as an empty string? Meaning the other conditions are not evaluating to true due to misspellings, capital letters, or something else? – Arthur Noort Apr 28 at 19:03
  • Maybe change SET @state = RequestParameter("mx_state") to SET @state = "mx_state" ? – Michiel van Gaalen Apr 28 at 19:07
  • @ArthurNoort, thanks for thinking with me. I've just performed several form submissions to check if the namings or names are the issue, but this is working like it should. For example: "State__c", RequestParameter("ca_state") added the state to Sales cloud – Daan Kramer Apr 28 at 19:13
  • I’d try to print the @state variable on your thank you page to check if the ampscript variable is filled. If that’s filled with the correct value there’s something going wrong in the createSalesforceObject function. I wouldn’t be surprised since this can be quite sensitive (e.g. a pick list not accepting other values). – Arthur Noort Apr 28 at 20:52
  • 2
    (spoke to Daan) personally. The dropdown is shown dynamically by use of client-side javascript. I think it could the case that because there is only 1 dropdown value in existence on client-side, there might be an issue with the if-statement after form submission. I suggested to use a single picklist-value name, because there will be only one available at client side. – RickForce Apr 29 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.