APIs & Integrations

LKallaur
Member

HubDB foreign ID column - Foreign table id must be defined error

Hello, I'm trying to create a table that contains a column with type=FOREIGN_ID.

I'm using POST /cms/v3/hubdb/tables.

Here's my request body:

 

 

{
    "label": "Privacy Policy Sections",
    "name": "privacy_policy_sections",
    "columns": [
        {
            "name": "order",
            "label": "Order",
            "type": "NUMBER",
            "foreignIdsById": {},
            "foreignIdsByName": {}
        },
        {
            "name": "title",
            "label": "Title",
            "type": "TEXT",
            "foreignIdsById": {},
            "foreignIdsByName": {}
        },
        {
            "name": "chapters",
            "label": "Chapters",
            "type": "FOREIGN_ID",
            "foreignTableId": 5288365,
            "foreignColumnId": 1,
            "foreignIds": [
                {
                    "id": "56153825340",
                    "name": "Information About You That You Share With Us Directly",
                    "type": "foreignid"
                },
                {
                    "id": "56153825341",
                    "name": "Information You Generate Using Our Services",
                    "type": "foreignid"
                },
                {
                    "id": "56153825342",
                    "name": "Cookies and Other Automated Information Collection",
                    "type": "foreignid"
                },
                {
                    "id": "56153825343",
                    "name": "Payment Information",
                    "type": "foreignid"
                },
                {
                    "id": "56153825344",
                    "name": "Customer Support Correspondence",
                    "type": "foreignid"
                },
                {
                    "id": "56153825345",
                    "name": "Other Sources",
                    "type": "foreignid"
                },
                {
                    "id": "56153825346",
                    "name": "With Affiliated Entities",
                    "type": "foreignid"
                },
                {
                    "id": "56153825347",
                    "name": "With Third-Party Service Providers",
                    "type": "foreignid"
                },
                {
                    "id": "56153825348",
                    "name": "Safety, Security, and Compliance with Law",
                    "type": "foreignid"
                },
                {
                    "id": "56153825349",
                    "name": "Sale or Merger",
                    "type": "foreignid"
                },
                {
                    "id": "56153825350",
                    "name": "Other Third Parties",
                    "type": "foreignid"
                },
                {
                    "id": "56153825351",
                    "name": "Accessing and Deleting Personal Information Held by Roofle",
                    "type": "foreignid"
                },
                {
                    "id": "56153825352",
                    "name": "Opting Out of Promotional Communications from Roofle",
                    "type": "foreignid"
                }
            ],
            "foreignIdsById": {
                "56153825340": {
                    "id": "56153825340",
                    "name": "Information About You That You Share With Us Directly",
                    "type": "foreignid"
                },
                "56153825341": {
                    "id": "56153825341",
                    "name": "Information You Generate Using Our Services",
                    "type": "foreignid"
                },
                "56153825342": {
                    "id": "56153825342",
                    "name": "Cookies and Other Automated Information Collection",
                    "type": "foreignid"
                },
                "56153825343": {
                    "id": "56153825343",
                    "name": "Payment Information",
                    "type": "foreignid"
                },
                "56153825344": {
                    "id": "56153825344",
                    "name": "Customer Support Correspondence",
                    "type": "foreignid"
                },
                "56153825345": {
                    "id": "56153825345",
                    "name": "Other Sources",
                    "type": "foreignid"
                },
                "56153825346": {
                    "id": "56153825346",
                    "name": "With Affiliated Entities",
                    "type": "foreignid"
                },
                "56153825347": {
                    "id": "56153825347",
                    "name": "With Third-Party Service Providers",
                    "type": "foreignid"
                },
                "56153825348": {
                    "id": "56153825348",
                    "name": "Safety, Security, and Compliance with Law",
                    "type": "foreignid"
                },
                "56153825349": {
                    "id": "56153825349",
                    "name": "Sale or Merger",
                    "type": "foreignid"
                },
                "56153825350": {
                    "id": "56153825350",
                    "name": "Other Third Parties",
                    "type": "foreignid"
                },
                "56153825351": {
                    "id": "56153825351",
                    "name": "Accessing and Deleting Personal Information Held by Roofle",
                    "type": "foreignid"
                },
                "56153825352": {
                    "id": "56153825352",
                    "name": "Opting Out of Promotional Communications from Roofle",
                    "type": "foreignid"
                }
            },
            "foreignIdsByName": {
                "Information About You That You Share With Us Directly": {
                    "id": "56153825340",
                    "name": "Information About You That You Share With Us Directly",
                    "type": "foreignid"
                },
                "Information You Generate Using Our Services": {
                    "id": "56153825341",
                    "name": "Information You Generate Using Our Services",
                    "type": "foreignid"
                },
                "Cookies and Other Automated Information Collection": {
                    "id": "56153825342",
                    "name": "Cookies and Other Automated Information Collection",
                    "type": "foreignid"
                },
                "Payment Information": {
                    "id": "56153825343",
                    "name": "Payment Information",
                    "type": "foreignid"
                },
                "Customer Support Correspondence": {
                    "id": "56153825344",
                    "name": "Customer Support Correspondence",
                    "type": "foreignid"
                },
                "Other Sources": {
                    "id": "56153825345",
                    "name": "Other Sources",
                    "type": "foreignid"
                },
                "With Affiliated Entities": {
                    "id": "56153825346",
                    "name": "With Affiliated Entities",
                    "type": "foreignid"
                },
                "With Third-Party Service Providers": {
                    "id": "56153825347",
                    "name": "With Third-Party Service Providers",
                    "type": "foreignid"
                },
                "Safety, Security, and Compliance with Law": {
                    "id": "56153825348",
                    "name": "Safety, Security, and Compliance with Law",
                    "type": "foreignid"
                },
                "Sale or Merger": {
                    "id": "56153825349",
                    "name": "Sale or Merger",
                    "type": "foreignid"
                },
                "Other Third Parties": {
                    "id": "56153825350",
                    "name": "Other Third Parties",
                    "type": "foreignid"
                },
                "Accessing and Deleting Personal Information Held by Roofle": {
                    "id": "56153825351",
                    "name": "Accessing and Deleting Personal Information Held by Roofle",
                    "type": "foreignid"
                },
                "Opting Out of Promotional Communications from Roofle": {
                    "id": "56153825352",
                    "name": "Opting Out of Promotional Communications from Roofle",
                    "type": "foreignid"
                }
            }
        },
        {
            "name": "description",
            "label": "Description",
            "type": "RICHTEXT",
            "foreignIdsById": {},
            "foreignIdsByName": {}
        }
    ],
    "useForPages": false,
    "allowChildTables": false,
    "enableChildTablePages": false,
    "allowPublicApiAccess": false
}

 

 

 

I receive the error:

 

 

Foreign table id must be defined: {name='chapters', label=Chapters, type=FOREIGN_ID, id=0, deleted=false, options=[], foreignTableId0, width=null}

 

 

 

But I have in request "foreignTableId": 5288365 for column with "type": "FOREIGN_ID" and table with this id exists.

What am I doing wrong?

8 Replies 8
frankfava
Participant | Platinum Partner
Participant | Platinum Partner

HubDB foreign ID column - Foreign table id must be defined error

@dennisedson Any thoughts on the foreignColumnId issue above? 

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

HubDB foreign ID column - Foreign table id must be defined error

Heyo friends!  Looks like this issue was fixed.  Was an internal issue!  Thanks for bringing it to our attention!

 

frankfava
Participant | Platinum Partner
Participant | Platinum Partner

HubDB foreign ID column - Foreign table id must be defined error

Thank you @dennisedson.

It is now indeed working. The only im having now is that the selected "foreignColumnId" doesnt correctly map over, it just defaults to showing the foreign id value in the related dropdown.

Any Ideas?

Screen Shot 2022-01-08 at 1.12.58 pm.png

Screen Shot 2022-01-08 at 1.13.10 pm.png

Screen Shot 2022-01-08 at 1.13.43 pm.png

   

Screen Shot 2022-01-08 at 1.13.58 pm.png

 

0 Upvotes
symball
Participant

HubDB foreign ID column - Foreign table id must be defined error

Sorry to spam but, I too am having this same issue and it's a blocker that needs to be addressed. @webdew , please assume the information in request is correct and the table does exist. Can you give a full example of how the request would look to create a table. For example:

 

{
  "name": "table_name",
  "useForPages": false,
  "label": "Table label",
  "allowChildTables": false,
  "allowPublicApiAccess": false,
  "dynamicMetaTags": {},
  "enableChildTablePages": false,
  "columns": [
    {
      "name": "normal_column",
      "label": "Normal column",
      "width": 330,
      "type": "TEXT"
    },
    {
      "name": "foreign_column",
      "label": "Foreign Column",
      "foreignTableId": 5315350,
      "foreignColumnId": 1,
      "foreignIds": [
        {
          "name": "EXAMPLE_1",
          "id": "63100937357",
          "type": "foreignid"
        },
        {
          "name": "EXAMPLE_2",
          "id": "63100951149",
          "type": "foreignid"
        },
        {
          "name": "EXAMPLE_3",
          "id": "63100937361",
          "type": "foreignid"
        }
      ],
      "type": "FOREIGN_ID"
    },
  ]
}
0 Upvotes
webdew
Guide | Diamond Partner
Guide | Diamond Partner

HubDB foreign ID column - Foreign table id must be defined error

Hi @LKallaur ,

According to this error, you have to create a table of "chapters" into the hubDB and then pass correct table ID and rows ID into new table for forign key.

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 Upvotes
LKallaur
Member

HubDB foreign ID column - Foreign table id must be defined error

Hi, I've created a table of "chapters" before I tried to create the second table. And all values that I used in the request are real values from "chapters" table (foreignTableId, foreignColumnId, foreignIds and so on). 

0 Upvotes
frankfava
Participant | Platinum Partner
Participant | Platinum Partner

HubDB foreign ID column - Foreign table id must be defined error

Any progress with this @LKallaur , im having the same issue

0 Upvotes
LKallaur
Member

HubDB foreign ID column - Foreign table id must be defined error

No, I wasn't able to find a solution

0 Upvotes