- Available Since API Version – 2.0\
The BooleanField type is used to represent boolean fields in Octopus API. BooleanField objects contain the following properties:
-
Value - A boolean value containing the value of the field. May be either true or false.\
-
DisplayValue - A string value containing the boolean value formatted for display.\
Basic Read Request
The highlighted sections in the following example illustrates the syntax for a request for the default value of a BooleanField in a Read method call.
Request
{
"AbEntry":{
"Scope":{
"Fields":{
"Key": 1,
"Lead": 1
}
},
"Criteria":{
"SearchQuery": {
"CompanyName": {
"$EQ": "Beach Cycle and Sport"
}
}
}
}
}
Response
{
"Code":0,
"AbEntry":{
"Data":[
{
"Key":"Q29udGFjdAlERU1PXzJDCTE=",
"Lead":false
}
]
}
}
Detailed Read Request
The following example illustrates the syntax for a request for all properties of a BooleanField in a Read method call.
Request
{
"AbEntry":{
"Scope":{
"Fields":{
"Key":1,
"Lead":{
"Value":1,
"DisplayValue":1
}
}
},
"Criteria":{
"SearchQuery":{
"CompanyName":{
"$EQ":"Beach Cycle and Sport"
}
}
}
}
}
Response
{
"Code":0,
"AbEntry":{
"Data":[
{
"Key":"Q29udGFjdAlERU1PXzJDCTE=",
"Lead":{
"Value":false,
"DisplayValue":"No"
}
}
]
}
}
Basic Create/Update Request
The following example illustrates the syntax for including a BooleanField in a Create or Update method call.
Request
{
"AbEntry":{
"Data":{
"Key":"{{AbEntryKey}}",
"Lead":true
}
}
}
Response
{
"Code":0,
"AbEntry":{
"Data":{
"Key":"Q29tcGFueQkxOTA5MTcyNTA5MTgxNTE3MDA0MzBDCTA=",
"Lead":true
}
}
}
Detailed Create/Update Request
The following example illustrates the syntax for including a BooleanField in a Create or Update method call.
Note that when including sub-properties of the field object in a Create/Update request, only the default property is used, and all other properties are ignored. In the case of a BooleanField, the "Value" is the default property, and the "DisplayValue" property is ignored.
Request
{
"AbEntry":{
"Data":{
"Key":"{{AbEntryKey}}",
"Lead":{
"Value":true,
"DisplayValue":"Yes"
}
}
}
}
Response
{
"Code":0,
"AbEntry":{
"Data":{
"Key":"Q29tcGFueQkxOTA5MTcyNTA5MTgxNTE3MDA0MzBDCTA=",
"Lead":{
"Value":true,
"DisplayValue":"Yes"
}
}
}
}
Common Pitfalls
The following are some examples that illustrate incorrect syntax for including BooleanField in requests.
Invalid Create/Update Request - String or Numeric Value
The default Value property of a BooleanField is a boolean, and numeric and string types are not valid. Even if the Value in question is a string or numeric representation of a boolean, the request is invalid.
In the Update example below, the call will fail because the Value is passed as a string.
{
"AbEntry":{
"Data":{
"Key":"{{AbEntryKey}}",
"Lead":"true"
}
}
}
Invalid Create/Update Request - Table Value
Although they are conceptually similar to single-value table fields, BooleanField fields do not support using array syntax for setting or retrieving the field value. This is in contrast to EnumField fields which use the array syntax.
In the Read example below, the call will fail because the value of the field is requested as an array of objects, instead of as a single object or value.
{
"AbEntry":{
"Scope":{
"Fields":{
"Key":1,
"Lead":[
{
"Value":1,
"DisplayValue":1
}
]
}
},
"Criteria":{
"SearchQuery":{
"CompanyName":{
"$EQ":"Beach Cycle and Sport"
}
}
}
}
}
Invalid Create/Update Request - Missing Value
When setting the value for a BooleanField using the detailed syntax in a Create/Update request, you must include the Value of the value that you want to set. Passing only the DisplayValue will result in the value not being set correctly.
In the Update example below, the call will fail because the Value property is missing from the request.
{
"AbEntry":{
"Data":{
"Key":"{{AbEntryKey}}",
"Lead":{
"DisplayValue":"No"
}
}
}
}
Invalid Create/Update Request - Mismatched Value and DisplayValue
When setting the value for a BooleanField in a Create or Update request, only the Value property of the field is observed, and the DisplayValue property is ignored.
In the example below, a DisplayValue is passed that does not match the supplied Value. This request will succeed; however it may have unintended effects, as the value of the field will be set to the value passed as the Value (in this case true), and not the "DisplayValue" (in this case, "No").
{
"AbEntry":{
"Data":{
"Key":"{{AbEntryKey}}",
"Lead":{
"Value":true,
"DisplayValue":"No"
}
}
}
}