Question about Forms API & Picklist Visibility Rules

Jose_Rafael_Par
Level 3

Question about Forms API & Picklist Visibility Rules

Hello, my company is updating our state/country integration values in Salesforce, so I need to update all our forms to have the new country codes instead of name values. I've gotten the API to work to update the country field and our opt-in checkbox visibility rules, but I'm struggling with the State visibility rule.

I'm grabbing the rules from a GET call and just changing the "United States" and "Canada" to "US" and "CA" the way I did for the others, but I'm consistently getting a 709 error that reads "Field of type radio buttons, checkboxes and select should have picklist values." Has anyone worked with updating form visibility rules via the API? Any idea what's wrong with the message body below? I'm identifying the "picklistFilterValues" , and they're all already entered as values in the State field.

{  
"rules":[
{
"subjectField":"Country",
"operator":"is",
"values":[
"US"
],
"altLabel":"State",
"picklistFilterValues":[
{
"label":"AK",
"value":"AK"
},
{
"label":"AL",
"value":"AL"
},
{
"label":"AR",
"value":"AR"
},
{
"label":"AZ",
"value":"AZ"
},
{
"label":"CA",
"value":"CA"
},
{
"label":"CO",
"value":"CO"
},
{
"label":"CT",
"value":"CT"
},
{
"label":"DC",
"value":"DC"
},
{
"label":"DE",
"value":"DE"
},
{
"label":"FL",
"value":"FL"
},
{
"label":"GA",
"value":"GA"
},
{
"label":"HI",
"value":"HI"
},
{
"label":"IA",
"value":"IA"
},
{
"label":"ID",
"value":"ID"
},
{
"label":"IL",
"value":"IL"
},
{
"label":"IN",
"value":"IN"
},
{
"label":"KS",
"value":"KS"
},
{
"label":"KY",
"value":"KY"
},
{
"label":"LA",
"value":"LA"
},
{
"label":"MA",
"value":"MA"
},
{
"label":"MD",
"value":"MD"
},
{
"label":"ME",
"value":"ME"
},
{
"label":"MI",
"value":"MI"
},
{
"label":"MN",
"value":"MN"
},
{
"label":"MO",
"value":"MO"
},
{
"label":"MS",
"value":"MS"
},
{
"label":"MT",
"value":"MT"
},
{
"label":"NC",
"value":"NC"
},
{
"label":"ND",
"value":"ND"
},
{
"label":"NE",
"value":"NE"
},
{
"label":"NH",
"value":"NH"
},
{
"label":"NJ",
"value":"NJ"
},
{
"label":"NM",
"value":"NM"
},
{
"label":"NV",
"value":"NV"
},
{
"label":"NY",
"value":"NY"
},
{
"label":"OH",
"value":"OH"
},
{
"label":"OK",
"value":"OK"
},
{
"label":"OR",
"value":"OR"
},
{
"label":"PA",
"value":"PA"
},
{
"label":"RI",
"value":"RI"
},
{
"label":"SC",
"value":"SC"
},
{
"label":"SD",
"value":"SD"
},
{
"label":"TN",
"value":"TN"
},
{
"label":"TX",
"value":"TX"
},
{
"label":"UT",
"value":"UT"
},
{
"label":"VA",
"value":"VA"
},
{
"label":"VT",
"value":"VT"
},
{
"label":"WA",
"value":"WA"
},
{
"label":"WI",
"value":"WI"
},
{
"label":"WV",
"value":"WV"
},
{
"label":"WY",
"value":"WY"
}
]
},
{
"subjectField":"Country",
"operator":"is",
"values":[
"CA"
],
"altLabel":"Province",
"picklistFilterValues":[
{
"label":"Alberta",
"value":"AB"
},
{
"label":"British Columbia",
"value":"BC"
},
{
"label":"Manitoba",
"value":"MB"
},
{
"label":"New Brunswick",
"value":"NB"
},
{
"label":"Newfoundland and Labrador",
"value":"NL"
},
{
"label":"Northwest Territories",
"value":"NT"
},
{
"label":"Nova Scotia",
"value":"NS"
},
{
"label":"Nunavut",
"value":"NU"
},
{
"label":"Ontario",
"value":"ON"
},
{
"label":"Prince Edward Island",
"value":"PE"
},
{
"label":"Quebec",
"value":"QC"
},
{
"label":"Saskatchewan",
"value":"SK"
},
{
"label":"Yukon",
"value":"YT"
}
]
}
],
"ruleType":"show"
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I've spent the past couple hours stuck on this, so any help would be really appreciated. Thank you!

15 REPLIES 15
SanfordWhiteman
Level 10 - Community Moderator

Re: Question about Forms API & Picklist Visibility Rules

Make you a deal, highlight that as actual JSON (JS in the syntax highlighter) and I'll figure it out for you. 

Jose_Rafael_Par
Level 3

Re: Question about Forms API & Picklist Visibility Rules

Good point, Sanford, I've both changed the syntax and ran my original rules through a JSON formatter to get it a bit more legible. 

SanfordWhiteman
Level 10 - Community Moderator

Re: Question about Forms API & Picklist Visibility Rules

Can I see your form on a page as well (I will grab the current form descriptor from there)?

Jose_Rafael_Par
Level 3

Re: Question about Forms API & Picklist Visibility Rules

Michael_Florin
Level 10

Re: Question about Forms API & Picklist Visibility Rules

Was this ever solved? I'm having the exact same problem right now.

SanfordWhiteman
Level 10 - Community Moderator

Re: Question about Forms API & Picklist Visibility Rules

Do you have a small repro case (form and payload)?

Michael_Florin
Level 10

Re: Question about Forms API & Picklist Visibility Rules

Thanks Sanford. Let's see:

My page and form: https://marketo-demo.reply.eu/Visi_API.html

Visibility Rules for the field "State". The picklist shall change based on the selection in "Country".

 

Michael_Florin_0-1719862092788.png

 

Now I want to do this via API. Following the instruction here (https://developers.marketo.com/rest-api/assets/forms/#visibility_rule), this URL and Payload work fine:

POST: {{base_url}}/rest/asset/v1/form/1360/field/Email/visibility.json

BODY: 

 

 

visibilityRule={
    
    "ruleType":"show", 
    "rules":[
        {
        "subjectField": "LastName", 
        "operator": "isNotEmpty", 
        "values": [], 
        "altLabel": "Email:"
        }
    ]
}

 

 

Now, let's transfer this to the Country and State. In its basic form it would look like this:


POST: {{base_url}}/rest/asset/v1/form/1360/field/State/visibility.json

BODY:

 

visibilityRule={
    
    "ruleType":"show", 
    "rules":[
        {
        "subjectField": "Country", 
        "operator": "isNotEmpty", 
        "values": [], 
        "altLabel": "State:"
        }
    ]
}

 


Now I get this error message:

 

{
    "requestId": "d1f#1906fc9ebfd",
    "success": false,
    "warnings": [],
    "errors": [
        {
            "code": "709",
            "message": "Field of type radio buttons, checkboxes and select should have picklist values."
        }
    ]
}

 


Alright, both Country and State are select type fields, so what is this error message referring to? Country? State? Both?

Next try, and this payload is an exact copy of the respective GET request: {{base_url}}/rest/asset/v1/form/1360/fields.json

 

{
    "visibilityRules": [
        {
            "ruleType": "show",
            "rules": [
                {
                    "subjectField": "Country",
                    "operator": "is",
                    "values": ["Germany"]
                }
            ],

            "picklistValues": [
                {
                    "label": "Select...",
                    "value": ""
                },
                {
                    "label": "CA",
                    "value": "CA"
                },
                {
                    "label": "CO",
                    "value": "CO"
                }
            ]
        },
        {
            "ruleType": "show",
            "rules": [
                {
                    "subjectField": "Country",
                    "operator": "is",
                    "values": ["Austria"]
                }
            ],

            "picklistValues": [
                {
                    "label": "Select...",
                    "value": ""
                },
                {
                    "label": "AR",
                    "value": "AR"
                },
                {
                    "label": "AZ",
                    "value": "AZ"
                }
            ]
        }
    ]
}

 


Response:

 

{
    "success": false,
    "errors": [
        {
            "message": "Invalid ruleType.",
            "code": "701"
        }
    ],
    "requestId": "36f#1906fe772b6",
    "warnings": []
}

 


Any idea?

SanfordWhiteman
Level 10 - Community Moderator

Re: Question about Forms API & Picklist Visibility Rules

Sheesh. I get the same results and can’t find the hidden trick.

 

One thing: your last POST payload doesn’t look like the GET response in my tests. My GET and parallel POST is as below. But still I get the 709 error every time.

{
  "ruleType": "show",
  "rules": [
    {
      "subjectField": "Country",
      "operator": "is",
      "values": [
        "US"
      ],
      "altLabel": "US State:",
      "picklistFilterValues": [
        {
          "label": "Select..."
        },
        {
          "label": "AK",
          "value": "AK"
        },
        {
          "label": "AL",
          "value": "AL"
        },
        {
          "label": "AR",
          "value": "AR"
        }
      ]
    },
    {
      "subjectField": "Country",
      "operator": "is",
      "values": [
        "MX"
      ],
      "altLabel": "Mexican State:",
      "picklistFilterValues": [
        {
          "label": "Select..."
        },
        {
          "label": "Campeche",
          "value": "Campeche"
        },
        {
          "label": "Nayarit",
          "value": "Nayarit"
        },
        {
          "label": "Aguascalientes",
          "value": "Aguascalientes"
        }
      ]
    }
  ]
}

 

Michael_Florin
Level 10

Re: Question about Forms API & Picklist Visibility Rules

Thank you Sanford. I've asked Marketo Support to provide an example payload that works.