Skip to main content
Question

Creating a formula date/time field through the REST API

  • February 6, 2023
  • 0 replies
  • 178 views

Hello,

i seem to be having an issue regarding creating a formula date/time field using the REST API.

i get the field data from a different table and receive something like this

 {
        "appearsByDefault": false,
        "audited": false,
        "bold": false,
        "doesDataCopy": false,
        "fieldHelp": "",
        "fieldType": "timestamp",
        "findEnabled": false,
        "id": 415,
        "label": "Week Ending Date",
        "mode": "formula",
        "noWrap": true,
        "properties": {
            "allowNewChoices": false,
            "carryChoices": true,
            "defaultToday": false,
            "defaultValue": "",
            "displayDayOfWeek": false,
            "displayMonth": "number",
            "displayRelative": false,
            "displayTime": true,
            "displayTimezone": false,
            "foreignKey": false,
            "formula": "If(DayOfWeek(ToDate([Date Created])) = 5 , [Date Created]",
            "primaryKey": false,
            "sortAsGiven": false
        }

i then plug these in to create a new field in another app

{'label': fieldpull['label'],
'fieldType': fieldpull['fieldType'],
'properties':
{"formula": fieldpull['properties']["formula"]}}

but whenever my python script encounters a date-time formula field, it gives me this error
{'message': 'Bad Request', 'description': '[formula] property is not supported'}

does anyone know how to get around this error?
This topic has been closed for replies.

TylerBrezler
Forum|alt.badge.img+5

Although the API returns a response that shows the field type as "timestamp", that's actually not a specifiable field type when creating a field. Yes, this is confusing.

You must specify the field type "datetime" in order for the request to work.  Guess you'll probably have to create a condition to convert timestamp to datetime.