ed fbsg
ed fbsg

Reputation: 13

How to create a relationship using the Acumatica REST API

I would like to establish a relationship between a customer -> contact. In general, I would like to know the proper way of creating a relationship in Acumatica Rest API.

I send the following json body as a PUT using curl in php

I have tried passing in the ContactIDs in the Contacts array but It just tells me that I am missing fields such as DefAddressID but when I try to add the field it does not go away.

I am able to create the relationship from the contact by adding the customerid into the businessaccount field, But I would like to be able to create the relationship both ways.

{
  "AccountRef": {},
  "ApplyOverdueCharges": {
    "value": false
  },
  "AutoApplyPayments": {
    "value": false
  },
  "BillingAddressSameAsMain": {
    "value": true
  },
  "BillingContactSameAsMain": {
    "value": true
  },
  "CreatedDateTime": {
    "value": "2014-07-14T14:26:40.1+00:00"
  },
  "CurrencyID": {
    "value": "USD"
  },
  "Contacts": [
    {
      "ContactID": {
        "value": "12108"
      }
    },
    {
      "ContactID": {
        "value": "12107"
      }
    }
  ],
  "CurrencyRateType": {},
  "CustomerClass": {
    "value": "KEY"
  },
  "CustomerID": {
    "value": "FBSG2"
  },
  "CustomerName": {
    "value": "Faye Business Systems Group"
  },
  "EnableCurrencyOverride": {
    "value": true
  },
  "EnableRateOverride": {
    "value": false
  },
  "EnableWriteOffs": {
    "value": true
  },
  "FOBPoint": {},
  "LeadTimedays": {
    "value": 0
  },
  "LocationName": {
    "value": "Primary Location"
  },
  "MultiCurrencyStatements": {
    "value": false
  },
  "OrderPriority": {
    "value": 0
  },
  "ParentRecord": {},
  "PriceClassID": {},
  "PrintDunningLetters": {
    "value": false
  },
  "PrintInvoices": {
    "value": false
  },
  "PrintStatements": {
    "value": false
  },
  "ResidentialDelivery": {
    "value": false
  },
  "SaturdayDelivery": {
    "value": false
  },
  "SendDunningLettersbyEmail": {
    "value": false
  },
  "SendInvoicesbyEmail": {
    "value": false
  },
  "SendStatementsbyEmail": {
    "value": false
  },
  "ShippingAddressSameAsMain": {
    "value": true
  },
  "ShippingBranch": {},
  "ShippingContactSameAsMain": {
    "value": true
  },
  "ShippingRule": {
    "value": "Back Order Allowed"
  },
  "ShippingTerms": {},
  "ShippingZoneID": {},
  "ShipVia": {},
  "StatementCycleID": {
    "value": "EOM"
  },
  "StatementType": {
    "value": "Open Item"
  },
  "Status": {
    "value": "Active"
  },
  "TaxRegistrationID": {},
  "TaxZone": {},
  "Terms": {
    "value": "30D"
  },
  "WarehouseID": {},
  "WriteOffLimit": {
    "value": 20.0000
  },
  "custom": {},
  "files": []
},

I expect to be able to go into the customer account and see the contacts that I just related under the contact tab. I would also like to be able to go into the contact and see the customer.

Actual results: I get back errors Error: 'DefAddressID' cannot be empty.

Upvotes: 1

Views: 289

Answers (2)

samol518
samol518

Reputation: 1404

I think I understand your situation

You are trying to create a Contact directly from the Customer screen which is not possible. If you go to that screen in the UI, you might notice that their is a "Add Contact" button on the contact tab. This might give you the illusion that you can add a Contact from the Customer screen.

In fact, what this button does is open the Contact screen and prefill certain fields with values in regard to the customer where you were.

So if you want to create a Contact via the Web Services, you must go through the Contact entity in the Endpoint.

Upvotes: 1

ed fbsg
ed fbsg

Reputation: 13

This is not supported by the Acumatica API.

Upvotes: 0

Related Questions