Working With User Custom Fields
This tutorial is intended to provide some guidance on working with Club Automation's User Custom Fields feature.
The following operations are covered:
- List custom fields available in the system.
- Retrieve the values of custom fields for a specific user.
- Save new custom field values for a specific user.
Receive authentication token
Please refer to the Authentication Tutorial to learn how to obtain an access token.
List custom fields available in the system
The GET /custom-fields endpoint returns a listing of all custom fields setup for use in the entire instance.
Custom Fields can be of the following types:
- Currency
- Date
- List
- Numeric
- Text
A standard object describing each Custom Field will be returned. However only the List Custom Fields will
include udfValues. All other types are free-form and will include some data of the specified type.
After you have received an authentication token, you should be able to retrieve custom fields by following this example:
Once you make a call to this endpoint (example):
curl -X GET \
https://api.partners.daxko.com/api/v1/custom-fields \
-H 'Accept: */*' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.partners.daxko.com' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \You should receive a response similar to this :
{
"data": [
{
"udfName": "Anniversary Date",
"udfId": "4",
"udfType": "date",
"udfValues": []
},
{
"udfName": "External System ID",
"udfId": "26",
"udfType": "text",
"udfValues": []
},
{
"udfName": "Sales Associates",
"udfId": "8",
"udfType": "list",
"udfValues": [
"Bruce Wayne",
"Dick Grayson",
"Selena Kyle",
"Joker"
]
},
{
"udfName": "Jersey Number",
"udfId": "16",
"udfType": "numeric",
"udfValues": []
},
{
"udfName": "Nickname",
"udfId": "42",
"udfType": "text",
"udfValues": []
},
],
"success": true,
"error": null,
"formErrors": null
}An example of how to retrieve custom fields can be found here.
Retrieve the values of custom fields for a specific user
The GET /users/{userId}/custom-fields endpoint returns all user custom fields for the specified user.
A standard object will be returned containing the values saved for that user's profile in the Club Automation system. Currently
all data regardless of type will be returned as a string. If no value has been set for a Custom Field on a users account the
system will return a null. The exception to this is the Numeric field which defaults to the value of 0.
After you have received an authentication token, you should be able to retrieve custom fields by following this example:
By calling this endpoint, with the userId param in the path:
curl -X GET \
https://api.partners.daxko.com/api/v1/users/52752/custom-fields \
-H 'Accept: */*' \
-H 'Authorization: Bearer TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.partners.daxko.com' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \You get a response with user custom field values for the specified user :
{
"data": [
{
"udfName": "Anniversary Date",
"udfId": "4",
"udfValue": "12/02/2001"
},
{
"udfName": "External System ID",
"udfId": "26",
"udfValue": "90630000000gtfAAAQ"
},
{
"udfName": "Sales Associates",
"udfId": "8",
"udfValue": null
},
{
"udfName": "Sweatshirt Size",
"udfId": "15",
"udfValue": "XL"
},
{
"udfName": "Jersey Number",
"udfId": "16",
"udfValue": "0"
},
{
"udfName": "Nickname",
"udfId": "42",
"udfValue": null
}
],
"success": true,
"error": null,
"formErrors": null
}An example of how to retrieve custom field values can be found here.
Save new custom field values for a specific user
The POST /users/{userId}/custom-fields endpoint is used to save a new value for a User Custom Field for a specific user.
After you have received an authentication token, you should be able to update custom fields by following this example:
To make a successful call to this endpoint you need to forward :
- Query param
userID - JSON user custom field object (example) :
[
{
"udfId": "42",
"udfValue": "Two Face"
}
]Example Request :
curl -X POST \
https://api.partners.daxko.com/api/v1/users/52752/custom-fields \
-H 'Accept: */*' \
-H 'Authorization: Bearer TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Host: api.partners.daxko.com' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \
-H 'content-length: 57' \
-d '[
{
"udfId": "42",
"udfValue": "Two Face"
}
]'Once you make a successful call, you should expect the response to be :
{
"data": [],
"success": true,
"error": null,
"formErrors": null
}An example of how to update custom field values can be found here.