I’m using the Date Picker field in a custom module. When I set a date with a time through the REST APIs, the time portion is cropped and all that is stored is the date.
But if I use a Date Picker on a Contact, then I am able to store both date and time in the field.
As an example, I have Date Picker field in both Custom Module and Contact. In both the name is cf_training_start_date.
In contact, if I set field as follows
"cf_training_start_date": "2022-11-24T22:32:03.124Z"
the value is returned in GET /contact with time portion remaining in tact.
"cf_training_start_date": "2022-11-24T22:32:03-0800"
This is the desired behavior.
But if I submit the same value to start date of custom module:
"cf_training_start_date": "2022-11-24T22:32:03.124Z"
The Get /custom_module/cm_training returns just the date portion as in:
"cf_training_start_date": "2022-11-24"
This is NOT the desired behavior. I want the time portion persisted.
Below is the full REST API call for updating both.
Set date field on Contact (time portion is persisted)
curl --location --request PUT 'https://*.myfreshworks.com/crm/sales/api/contacts/16014198646' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token token=***' \
--data-raw '{
"contact": {
"custom_field": {
"cf_training_start_date": "2022-11-24T22:32:03.124Z"
}
}
}'
Set date field on Custom Module (time portion is lost)
curl --location --request PUT 'https://*.myfreshworks.com/crm/sales/api/custom_module/cm_training/16001564207' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token token=****' \
--data-raw '{
"cm_training": {
"custom_field": {
"cf_training_start_date": "2022-11-24T22:32:03.124Z"
}
}
}'
What I want is to have time portion of date persisted in custom module date picker field like it works for contacts, accounts and deals.