Search code examples
restnetsuitesuitecloud

Netsuite - Custom List related to a object field


I am able to get fields related to an object doing a GET request:

https://[...].suitetalk.api.netsuite.com/services/rest/record/v1/metadata-catalog/customer

And sending as header: Accept: application/schema+json

On this response I get a custom field called: "custentity_companypublicprivate", which in the UI is a dropdown, and the values on this dropdown are a custom list.

Manually I was able to get which is the custom list related: "customlist_compnaypublicprivate"

But I need to get this relationship through code since I need to do this for all fields which are a custom list and in the response I can not find any information which tells me which is the custom list related.

This is the definition of the object:

"custentity_companypublicprivate": {
            "type": "object",
            "properties": {
                "id": {
                    "title": "Internal identifier",
                    "type": "string"
                },
                "refName": {
                    "title": "Reference Name",
                    "type": "string"
                },
                "externalId": {
                    "title": "External identifier",
                    "type": "string"
                },
                "links": {
                    "title": "Links",
                    "type": "array",
                    "readOnly": true,
                    "items": {
                        "$ref": "/services/rest/record/v1/metadata-catalog/nsLink"
                    }
                }
            }
        }

Is there a way to do this?. Thanks in advance for your help.


Solution

  • Another option is to query using SuiteQL.

    https://#########.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=1000&offset=0
    

    Query:

    {
    "q": "SELECT * FROM CustomField where fieldtype = 'ENTITY'"
    }
    

    Returns the list/record InternalId in fieldvaluetyperecord.

    Other queries:

    {
    "q": "SELECT * FROM CustomRecordType"
    }
    
    {
    "q": "SELECT * FROM CustomList"
    }
    
    {
    "q": "SELECT * FROM customlist_compnaypublicprivate"
    }