I am using Make to update a WIldApricot contactfield dropdown list to add a new value. Here’s the API call docs for the call I am using in the Make API call:
/accounts/{accountId}/contactfields/{contactFieldId}
Doing so appears to erases existing values set for contacts for this particular field.
The body of the call is as follows:
{
"FieldName": "testing-changes-viaAPI",
"IsRequired": false,
"AdminOnly": false,
"Access": "Public",
"FieldInstructions": "",
"Order": 1,
"FieldType": "Dropdown",
"AllowedValues": [
{
"Id": 20498444,
"Label": "item1",
"Value": "20498444",
"SelectedByDefault": false,
"Position": 0
},
{
"Id": 20498445,
"Label": "item2",
"Value": "20498445",
"SelectedByDefault": false,
"Position": 1
},
{
"Label": "item3",
"SelectedByDefault": false,
"Position": 2
},
{
"Label": "item4",
"SelectedByDefault": false,
"Position": 3
}
],
"Id": 15979763
}
Hopefully you can help me understand what is going on, whether my ContactFields PUT request is not correct or whether this is in fact a bug in the API.
Here’s my short walk through:
And attached is the scenario I have built. If you create a dropdown list and adjust the field ID in the last module to reflect the new field ID you can replicate this issue quite easily on your end. I hope I am just not sending the right body for the /accounts/{accountid}/contactfields/{contactfieldID} call and a simple fix will help not erase existing data in the database.
blueprint (25).json (12.1 KB)
1 Like
A bit of an Update. I went to Postman to see what’s happening to the underlying picklist values after I call the PUT to update the AllowedValues array in the body. It looks like exisiting allowed values and any new allowed values I add all are assigned a new Id and Value, rendering any existing data that has used this picklist invalid, resetting the value to null in the underlying record.
The PUT is a destructive change and doesn’t consider whether the AllowedValues already exist in the picklist and essentially erases the dropdown’s allowed values to the new set I put in the PUT. Even if I keep the Id and Value keys with the old ID pre-PUT, the API call resets the IDs and I can see that if I read the contactfields definition with a GET.
I opened a ticket with WildApricot support hoping this is an unintended bug in the API – this call is supposed to update the existing definition and it does for the most part with other key value pairs but for AllowedValues array it erases any existing allowed values and replaces them with brand new values that have been provided in the PUT even if they already exist in the field’s definition.
This is the AllowedValues array I am sending in the body. Label and Value are the only 2 required fields to send here, but if item1, item2, item5 or item6 already exist, their IDs and Values are overwritten with this PUT redefining the picklist and erasing any existing data for records that have set this field. NOT GOOD!
{
"FieldName": "testing-changes-viaAPI",
"IsRequired": false,
"AdminOnly": false,
"Access": "Public",
"FieldInstructions": "",
"Order": 1,
"FieldType": "Dropdown",
"Type": "Choice",
"AllowedValues": [
{
"Label": "item5",
"Value": ""
},
{
"Label": "item6",
"Value": ""
},
{
"Label": "item1",
"Value": ""
},
{
"Label": "item2",
"Value": ""
}
],
"Id": 15981674
}
3 Likes
Update 2: I don’t expect the API to be updated anytime soon. Bug or not if you want to update the dropdown values (or any radio buttons or checkboxes) the only solution is to shapshot the database records that have the field in question you wish to update via the api and then restore the records, reconnecting the state of the field with the new IDs assigned.
I created 3 scenarios — 1 to snapshot, 1 to update the custom field with a new dropdown value and 1 to restore the data back to its original state before the new pick list value was added.
Scenario 1: Saving Contacts & Dropdown Values
Scenario 2: Adding a new value to an existing picklist item in dropdown contact field
Scenario 3: Restoring Dropdown Values and Updating Affected Contacts
Here’s a video on how it works:
If you’d like the scenarios please get in touch Contact Us Today - NewPath Consulting
3 Likes