I want to create vendor from C# application using AIF VendorService given by MS Dynamics AX 2012. R3
When I run the app, on create() method, I get an exception and AX gives error. "PartyId must be filled in".
I am using the following code:
The C# Code
VendTableServiceClient vendSvcClient = new VendTableServiceClient();
CallContext callContext = new CallContext();
AxdVendTable axdVendor = new AxdVendTable();
AxdEntity_VendTable[] vendorList = new AxdEntity_VendTable[1];
EntityKey[] entityKey;
AxdEntity_VendTable vendTable = new AxdEntity_VendTable();
vendTable.Name = "1234";
vendTable.VendGroup = "ABCD";
vendTable.Currency = "PKR";
vendTable.PaymTermId = "ADP";
vendTable.PaymMode = "CHQ";
AxdEntity_DirPartyTable_DirOrganization org = new AxdEntity_DirPartyTable_DirOrganization()
{
KnownAs = "vabu1",
NameAlias = "vabu1",
Name = "Vendor Abubaker",
OrganizationName = new AxdEntity_OrganizationName[1],
PartyNumber = dirPatyTable.PartyNumber,
//PrimaryAddressLocation = "0",
PhoneticName = "VAbubaker"
};
AxdEntity_OrganizationName orgName = new AxdEntity_OrganizationName()
{
Name = "Vendor Abubaker123"
};
org.OrganizationName[0] = orgName;
AxdEntity_DirPartyPostalAddressView[] postalAddView = new AxdEntity_DirPartyPostalAddressView[1];
postalAddView[0] = new AxdEntity_DirPartyPostalAddressView()
{
BuildingCompliment = "Builing",
City = "KARACHI",
CountryRegionId = "PK",
IsPrimary = (AxdExtType_LogisticsIsPrimaryAddress)AxdEnum_NoYes.Yes,
LocationName = "Primary",
Roles = "Business",
State = "ALL",
ZipCode = "",
Street = "RRR"
};
vendTable.DirPartyTable = new AxdEntity_DirPartyTable_DirPartyTable[1] { org };
vendorList[0] = vendTable;
axdVendor.VendTable = vendorList;
axdVendor.DocPurpose = AxdEnum_XMLDocPurpose.Original;
axdVendor.DocPurposeSpecified = true;
entityKey = vendSvcClient.create(callContext, axdVendor);
Questions
Is there anything I have missed? When I don't add dirpartytable, it creates vendor but with empty Address and all (ofcourse). What could be the reason of this error?