Retrieving Custom Field Items Using REST

So, you've created some custom fields for your projects, tasks and other Project Insight items?

Great! Now, you're probably wondering how to extract those pesky custom field items without having to hard code each one in your nifty application. Here is a quick guide to help you achieve greatness.

If you haven't done so already, I advise reading this guide and manual documentation about Custom Fields.

On the "Advanced" tab within the custom field definition form, you'll find the "Id" of the Custom Field Definition to make your REST calls and retrieve the object.


cURL

curl -X GET \
  https://yourdomain.projectinsight.net/api/custom-field/5c65c8d6-e178-41dd-9069-3fe635477d4b \
  -H 'api-token: {YOUR_API_TOKEN}' \
  -H 'cache-control: no-cache' \


Request URL

GET https://yourdomain.projectinsight.net/api/custom-field/5c65c8d6-e178-41dd-9069-3fe635477d4b HTTP/1.1
api-token: {YOUR_API_TOKEN}
Cache-Control: no-cache

If successful, you will want to look for a property called "ListItems". You can reference the model here in the api guide.


Here is a sample of the response object

{
    "ListItems": [
        {
            "Value": "f067bd3e-cfd2-4bb1-8835-a36946fdbf0b",
            "Name": "$10,000 - $20,000",
            "Order": 1
        },
        {
            "Value": "5544db9b-7ab8-46fa-aff5-a4ba397bb2ce",
            "Name": "$20,000 - $50,000",
            "Order": 2
        },
        {
            "Value": "34052836-e376-4ca2-b69e-7f194f9c4b13",
            "Name": "$50,000 - $100,000",
            "Order": 3
        },
        {
            "Value": "f06986be-7835-4395-a638-d3e60109e31a",
            "Name": "$100K+",
            "Order": 4
        }
    ],
    "InputControlType": 14,
    "Name": "Project Budgets",
    "HelpText": "",
    "InputLocation": 0,
    "DisplayLocation": 0,
    "EnableAsAvailableColumnInTable": true,
    "DisplayColumnWidth": 100,
    "IsReadOnly": false,
    "FieldNumber": 1,
    "DataType": 0,
    "DefaultValue": "",
    "ReadOnlyText": "",
    "IsRequired": false,
    "IsRequiredInline": false,
    "IsActive": true,
    "IsDefaultDisplayColumn": false,
    "IsShowAsReportFilter": false,
    "StyleTextCell": "",
    "StyleTextHeaderCell": "",
    "StyleText": "",
    "StyleDisplayText": "",
    "StyleTextHeader": "",
    "CssClass": "",
    "InputCssClass": "",
    "DisplayCssClass": "",
    "OnChange": "",
    "DisplayFormatMask": "",
    "TextBoxRows": -1,
    "TextAlign": 2,
    "ListRepeatColumns": 0,
    "IsFinancialData": false,
    "Id": "5c65c8d6-e178-41dd-9069-3fe635477d4b",
    "IdExternal": null
}

Depending on the type of input control (mainly combobox, radiobutton and checkbox) you'll be able to tap into the "List Values" properties, which you assigned within Project Insight (see screenshot).

(Click screenshot for full image)

You can now take all these tips; mash up together and implement your integration without issues!

Happy Coding!

Online 7/10/2017