We were working on a project that would pass our e-commerce orders into Acumatica through Web Service API.
As part of the order process, we need to search through Customers to get the one we need, and then we want to have ability to make change to this customer data based on primary key, i.e. BAccountID; however, when I used Web Service API "AR303000Export" to get customer info, I didn't see "BAccountID" in the data that I was getting from Acumatica, therefore I couldn't update that Business Account record based on primary keys (BAccountID and CompanyID, we already have CompanyID).
Is there anyway to get primary key values when doing search through Web Service API?
I noticed I might be able to use "AcctCD", which is called "Customer ID" to update, however, I'm not sure whether that Customer ID is unique or not in database, since it is not specified as Primary key...
Any help would be really appreciated.
Thanks.
Your specific question is how to get BAccountID
, and you can - so I'll answer that question. But you probably do want to work with AcctCD
.
This snippet of code builds the command list for AR303000Export
var commandgroup = new Command[]
{
AR303000Schema.CustomerSummary.ServiceCommands.EveryCustomerID
, WSTools.NewA4Field(AR303000Schema.CustomerSummary.CustomerID.ObjectName, "DefContactID")
, AR303000Schema.CustomerSummary.CustomerID
, AR303000Schema.CustomerSummary.CustomerName
, WSTools.NewA4Field(AR303000Schema.CustomerSummary.CustomerID.ObjectName, "BAccountID")
, WSTools.NewA4Field(AR303000Schema.CustomerSummary.CustomerID.ObjectName, "Type")
,AR303000Schema.CustomerSummary.Status
, AR303000Schema.GeneralInfoMainContact.Phone1
, AR303000Schema.GeneralInfoMainContact.Phone2
, WSTools.NewA4Field(AR303000Schema.GeneralInfoMainContact.Phone1.ObjectName, "Phone1Type")
, WSTools.NewA4Field(AR303000Schema.GeneralInfoMainContact.Phone1.ObjectName, "Phone2Type")
WSTools.NewA4Field(AR303000Schema.CustomerSummary.CustomerID.ObjectName, "LastModifiedDateTime")
};
You'll notice that some interesting things are just not exposed in the strongly typed schema, but still available if you know how to build the command to reference the field. (Such as the type of phone number in Phone1
being in Phone1Type
).
In your case, you need a command to export BAccountID
from the same internal object name as CustomerID
:
WSTools.NewA4Field(AR303000Schema.CustomerSummary.CustomerID.ObjectName, "BAccountID")
in your export command list. (it is 5th in the snippet above).
There are many ways to build the "Field" object - I have a utility method for that:
public static AcumaticaWS.Field NewA4Field(string objName, string fldName)
{
AcumaticaWS.Field nv = new AcumaticaWS.Field();
nv.ObjectName = objName;
nv.FieldName = fldName.TrimEnd();
return nv;
}
Hope this helps!