Discussions

 View Only

Creating a formula date/time field through the REST API

  • 1.  Creating a formula date/time field through the REST API

    Posted 02-06-2023 18:12
    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?