I’ve specified ‘bool’, ‘booleancheckbox’, for type and field type and these values for options
[{‘label’:‘True’, ‘value’:True},{‘label’:‘False’, ‘value’:False}] using contact properties API
I update this contact using Python. I specify value as boolean, then encode it in JSON and update the contact.
But when I request this contact back the property is a string like “true” or “false” and not JSON true or false.
How do I get a real boolean like is_contact field in contact object? “is-contact”:true
What I have:
{“value”:“true”}
what I want
{“value”:true}
@pmanca Hi, could you take a look at my problem as well, please? Is it possible to have a property with a boolean value like {“value”:true} and not {“value”:“true”}? If it’s possible, how to define such property? What JSON parameters to send when creating it?
I’ve created it with there params and when I update it with true and the request it back I get “true”
“name”: “bool_prop”,
“label”: “A New Custom Property”,
“description”: “A new property for you”,
“groupName”: “my_props”,
“type”: “bool”,
“fieldType”: “booleancheckbox”,
“formField”: false,
“displayOrder”: 6,
“options”: [
{“label”:“True”,
“value”:true},
{“label”:“False”,
“value”:false}
]
@Alexei_Vasilkov I was able to reproduce this on my end. The way the checkbox property type works, it stores it as a string and not as a boolean value. At the moment there isn’t a property type that will store a boolean value as a boolean. You will need to just write in the logic to handle them as strings on your end.
@Alexei_Vasilkov I just reached out to one of our internal Product Experts. Through the UI the property type for a checkbox by default is enumeration. This is why it gets casted to a string. You can set the type of the property to a boolean through the API. This will get you the functionality that you are looking for. Here is the link to the docs for reference.
Hm. I did specify bool and I did create the property through API and not UI
“type”: “bool”,
I tried creating it with empty []… wait…maybe I just need to not include options at all…
but I got an error if I didn’t specify any options, and so I had to specify options.
b’{“status”:“error”,“message”:“Boolean properties must have exactly two options; one with a value of ‘true’, the other with a value of ‘false’”
Here’s exact json I sent
{“formField”: false, “label”: “DUMMY PROPERTY”, “options”: [], “description”: “”, “displayOrder”: 20, “type”: “bool”, “name”: “dummy_prop123”, “groupName”: “group_name_dummy”, “fieldType”: “booleancheckbox”}
Nope. same error even when I remove “options” completely from request
b’{“status”:“error”,“message”:“Boolean properties must have exactly two options; one with a value of ‘true’, the other with a value of ‘false’”
@Alexei_Vasilkov The boolean property was something we use to support but no longer. The team that I spoke to earlier about this is going to update the docs to reflect this change.