Update a custom field for an employee
Step 1: Retrieve the list of custom fields
Load the available custom fields in OnLocation (GET /customfield/element/staff).
The details of your employee custom fields will be returned. In this example, there's a checkbox custom field with the id 741.
[
{
"id": 741,
"created": "2021-11-25T12:17:27+13:00",
"modified": "2021-11-27T12:17:27+13:00",
"cf_tab_id": 89,
"is_visible": true,
"is_mandatory": true,
"is_unique": true,
"title": "Has a Driver License",
"created_by": 823431,
"modified_by": 823431,
"element_type": "checkbox"
}
]
Step 2: Retrieve the employee list
Retrieve your employee list (GET /staff).
Your employee list will be returned. In this example, you'll see an employee has a custom field in their profile with the id 741. The value is 0 which means the checkbox field is not selected in their profile.
{
"id": 823562,
"created": "2021-10-06T15:35:50+13:00",
"modified": "2021-10-06T16:35:50+13:00",
"account_status": "new",
"last_login": "2021-11-15T16:35:50+13:00",
"onsite_status": "offsite",
"name": "Staff Name",
"title": "Mr",
"altname": "Daffy",
"email": "example.staff@whosonlocation.com",
"phone": "0214445060",
"mobile": "0214445060",
"ice": "0214445060",
"setup_method": "manual",
"employee_id": 301,
"location": "Head Office",
"cur_location": "Head Office",
"department": "Administration",
"customfields": {
"741": 0,
}
}
Step 3: Update the employee profile
To update the custom field for the employee, fire a request to (PUT /staff/823562).
In this example, the employee's id is 823562 and custom field's id is 741. The value 1 means the driver license check box is selected.
{
"id": 823562,
"customfields": {
"741": 1
}
}