APIs & Integrations

alexluong1
Participant

Updating a field type from date to date time

SOLVE

Hi,

 

Not a developer but doing it out of necessity. I'm currently confused on how to change the type of a Deal field via API. I am specifically trying to change the type from datetime to date.

 

I was told by HubSpot support/product teams that I can convert my existing date fields into datetime fields via the API. The closest thing I am seeing in the API documentation provided (https://developers.hubspot.com/docs/api/crm/properties)  is the function for

PATCH/crm/v3/properties/{objectType}/{propertyName}

I'm confused because I'm not understanding if it will allow me to update the type, or just updates the values (which is what it seems like it does). 

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Updating a field type from date to date time

SOLVE

Hey @alexluong1 👋 Closing the loop on this one. I created a custom `date` property using the Properties API (this part can be done in-app as well) and successfully updated it (property itself) to be a datetime `type`.

 

Here's my quick test:

Create the Property

Request

curl --request POST \
  --url https://api.hubapi.com/crm/v3/properties/0-1 \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "hidden": false,
  "displayOrder": 2,
  "description": "string",
  "label": "Date 2",
  "type": "date",
  "groupName": "contactinformation",
  "name": "date_2",
  "fieldType": "date",
  "formField": false,
  "hasUniqueValue": false,
  "externalOptions": false
}'

Response

HTTP 201

{
  "updatedAt": "2024-05-28T20:38:09.910Z",
  "createdAt": "2024-05-28T20:38:09.910Z",
  "name": "date_2",
  "label": "Date 2",
  "type": "date",
  "fieldType": "date",
  "description": "string",
  "groupName": "contactinformation",
  "options": [],
  "createdUserId": "10233975",
  "updatedUserId": "10233975",
  "displayOrder": 2,
  "calculated": false,
  "externalOptions": false,
  "archived": false,
  "hasUniqueValue": false,
  "hidden": false,
  "modificationMetadata": {
    "archivable": true,
    "readOnlyDefinition": false,
    "readOnlyValue": false
  },
  "formField": false,
  "dataSensitivity": "non_sensitive"
}

Update the property type via an API call

Request

curl --request PATCH \
  --url https://api.hubapi.com/crm/v3/properties/0-1/date_2 \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "groupName": "contactinformation",
  "hidden": false,
  "displayOrder": 2,
  "description": "string",
  "type": "datetime",
  "fieldType": "date",
  "formField": false
}'

Response

HTTP 200

{
  "updatedAt": "2024-05-28T20:38:09.910Z",
  "createdAt": "2024-05-28T20:38:09.910Z",
  "name": "date_2",
  "label": "Date 2",
  "type": "datetime",
  "fieldType": "date",
  "description": "string",
  "groupName": "contactinformation",
  "options": [],
  "createdUserId": "10233975",
  "updatedUserId": "10233975",
  "displayOrder": 2,
  "calculated": false,
  "externalOptions": false,
  "archived": false,
  "hasUniqueValue": false,
  "hidden": false,
  "modificationMetadata": {
    "archivable": true,
    "readOnlyDefinition": false,
    "readOnlyValue": false
  },
  "formField": false,
  "dataSensitivity": "non_sensitive"
}

 

 

I hope this helps get folks moving forward! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Updating a field type from date to date time

SOLVE

Hey @alexluong1 👋 Closing the loop on this one. I created a custom `date` property using the Properties API (this part can be done in-app as well) and successfully updated it (property itself) to be a datetime `type`.

 

Here's my quick test:

Create the Property

Request

curl --request POST \
  --url https://api.hubapi.com/crm/v3/properties/0-1 \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "hidden": false,
  "displayOrder": 2,
  "description": "string",
  "label": "Date 2",
  "type": "date",
  "groupName": "contactinformation",
  "name": "date_2",
  "fieldType": "date",
  "formField": false,
  "hasUniqueValue": false,
  "externalOptions": false
}'

Response

HTTP 201

{
  "updatedAt": "2024-05-28T20:38:09.910Z",
  "createdAt": "2024-05-28T20:38:09.910Z",
  "name": "date_2",
  "label": "Date 2",
  "type": "date",
  "fieldType": "date",
  "description": "string",
  "groupName": "contactinformation",
  "options": [],
  "createdUserId": "10233975",
  "updatedUserId": "10233975",
  "displayOrder": 2,
  "calculated": false,
  "externalOptions": false,
  "archived": false,
  "hasUniqueValue": false,
  "hidden": false,
  "modificationMetadata": {
    "archivable": true,
    "readOnlyDefinition": false,
    "readOnlyValue": false
  },
  "formField": false,
  "dataSensitivity": "non_sensitive"
}

Update the property type via an API call

Request

curl --request PATCH \
  --url https://api.hubapi.com/crm/v3/properties/0-1/date_2 \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "groupName": "contactinformation",
  "hidden": false,
  "displayOrder": 2,
  "description": "string",
  "type": "datetime",
  "fieldType": "date",
  "formField": false
}'

Response

HTTP 200

{
  "updatedAt": "2024-05-28T20:38:09.910Z",
  "createdAt": "2024-05-28T20:38:09.910Z",
  "name": "date_2",
  "label": "Date 2",
  "type": "datetime",
  "fieldType": "date",
  "description": "string",
  "groupName": "contactinformation",
  "options": [],
  "createdUserId": "10233975",
  "updatedUserId": "10233975",
  "displayOrder": 2,
  "calculated": false,
  "externalOptions": false,
  "archived": false,
  "hasUniqueValue": false,
  "hidden": false,
  "modificationMetadata": {
    "archivable": true,
    "readOnlyDefinition": false,
    "readOnlyValue": false
  },
  "formField": false,
  "dataSensitivity": "non_sensitive"
}

 

 

I hope this helps get folks moving forward! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Updating a field type from date to date time

SOLVE

Hey, @alexluong1 👋 I am happy to set up a test using my dev portal. If it works, I'll post back here with the steps and any helpful details. 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes