To use this class method I have created all parmmethods in this class where i am using all those fields in this method to create vendor.
Before seeing this post please read the post That i posted earlier for creating the vendors.
http://krishhdax.blogspot.dk/2012/03/ax2012-import-vendors-from-csv-using.html
This post is just upgrade of my earlier logic to create vendor,multiple contacts informations.
public static void CreateVendor()
{
VendVendTableService vendVendTableService;
VendVendTable vendVendTable;
VendVendTable_VendTable vendTable;
VendVendTable_DirPartyPostalAddressView adresss;
VendVendTable_DirPartyTable_DirOrganiza1 dirPartyTable;
VendVendTable_DirPartyContactInfoView contactInfoPhone, contactInfoFax, contactInfoEmail,
contactInfoWeb;
VendVendTable_OrganizationName organizationName;
DirContactPersonsService dirContactPersonsService;
DirContactPersons dirContactPersons;
DirContactPersons_ContactPerson dirContactPersons_ContactPerson;
DirContactPersons_Person dirContactPersons_Person;
DirContactPersons_PersonName dirContactPersons_PersonName;
TaxVATNumTable taxVATNumTable;
LogisticsLocationRole logisticsLocationRole =
LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Business);
AifDimensionAttributeValueSet aifDimensionAttributeValueSet;
AifDimensionAttributeValue aifDimensionAttributeValue;
AifEntityKeyList aifEntityKeyList, aifEntityKeyList_DirContactPerson;
str fName, mName, lName;
;
vendVendTableService = vendVendTableService::construct();
vendVendTable = new VendVendTable();
vendTable = vendVendTable.createVendTable().addNew();
vendTable.parmAccountNum(vendorAccount);
vendTable.parmItemBuyerGroupId(buyerGroup);
vendTable.parmVendGroup(credGroup);
vendTable.parmCurrency(currency);
vendTable.parmName(name);
vendTable.parmVATNum(vATNum);
vendTable.parmPaymTermId(PaymTerms);
//This is validated and not found in Ax so update vendor after create or leave empty
vendTable.parmInvoiceAccount(InvoiceAccount);
vendTable.parmDlvTerm(deliveryTerms);
// Create dimension
if (defDimProject)
{
if (!aifDimensionAttributeValueSet)
{
aifDimensionAttributeValueSet = vendTable.createDefaultDimension();
aifDimensionAttributeValue = aifDimensionAttributeValueSet.createValues().addNew();
}
else
{
aifDimensionAttributeValue = aifDimensionAttributeValueSet.parmValues().addNew();
}
aifDimensionAttributeValue.parmName("Project");
aifDimensionAttributeValue.parmValue(defDimProject);
}
if (defDimDepartment)
{
if (!aifDimensionAttributeValueSet)
{
aifDimensionAttributeValueSet = vendTable.createDefaultDimension();
aifDimensionAttributeValue = aifDimensionAttributeValueSet.createValues().addNew();
}
else
{
aifDimensionAttributeValue = aifDimensionAttributeValueSet.parmValues().addNew();
}
aifDimensionAttributeValue.parmName("Department");
aifDimensionAttributeValue.parmValue(defDimDepartment);
}
if (vATNum && !TaxVATNumTable::exist(vendTable.parmVATNum(), countryRegionId))
{
taxVATNumTable.VATNum = vendTable.parmVATNum();
taxVATNumTable.CountryRegionId = countryRegionId;
taxVATNumTable.insert();
}
dirPartyTable = new VendVendTable_DirPartyTable_DirOrganiza1();
vendTable.createDirPartyTable().add(dirPartyTable);
dirPartyTable.parmLanguageId(language);
organizationName = dirPartyTable.createOrganizationName().addNew();
organizationName.parmName(name);
adresss = dirPartyTable.createDirPartyPostalAddressView().addNew();
adresss.parmCity(city);
adresss.parmCountryRegionId(countryRegionId);
adresss.parmStreet(street);
adresss.parmZipCode(zipCode);
adresss.parmRoles(logisticsLocationRole.Name);
contactInfoPhone = dirPartyTable.createDirPartyContactInfoView().addNew();
contactInfoPhone.parmLocationName(name);
contactInfoPhone.parmIsPrimary(NoYes::Yes);
contactInfoPhone.parmLocator(phone);
contactInfoPhone.parmType(LogisticsElectronicAddressMethodType::Phone);
contactInfoPhone.parmRoles(logisticsLocationRole.Name);
contactInfoPhone.parmIsLocationOwner(1);
contactInfoFax = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoFax.parmLocationName(name);
contactInfoFax.parmIsPrimary(NoYes::Yes);
contactInfoFax.parmLocator(fax);
contactInfoFax.parmType(LogisticsElectronicAddressMethodType::Fax);
contactInfoFax.parmRoles(logisticsLocationRole.Name);
contactInfoFax.parmIsLocationOwner(1);
contactInfoEmail = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoEmail.parmLocationName(name);
contactInfoEmail.parmIsPrimary(NoYes::Yes);
contactInfoEmail.parmLocator(email);
contactInfoEmail.parmType(LogisticsElectronicAddressMethodType::Email);
contactInfoEmail.parmRoles(logisticsLocationRole.Name);
contactInfoEmail.parmIsLocationOwner(1);
contactInfoWeb = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoWeb.parmLocationName(name);
contactInfoWeb.parmIsPrimary(NoYes::Yes);
contactInfoWeb.parmLocator(web);
contactInfoWeb.parmType(LogisticsElectronicAddressMethodType::URL);
contactInfoWeb.parmRoles(logisticsLocationRole.Name);
contactInfoWeb.parmIsLocationOwner(1);
aifEntityKeyList = vendVendTableService.create(vendVendTable);
dirContactPersonsService = DirContactPersonsService::construct();
dirContactPersons = new DirContactPersons();
if (contactId)
{
dirContactPersons_ContactPerson = dirContactPersons.createContactPerson().addNew();
dirContactPersons_ContactPerson.parmContactForPartyVendAccount(vendorAccount);
dirContactPersons_Person = dirContactPersons_ContactPerson.createPerson().addNew();
dirContactPersons_Person.parmNameAlias(contactId);
dirContactPersons_PersonName = dirContactPersons_Person.createPersonName().addNew();
[fName, mName, lName] = DirPerson::splitNameParts(contactId);
dirContactPersons_PersonName.parmFirstName(fName);
dirContactPersons_PersonName.parmMiddleName(mName);
dirContactPersons_PersonName.parmLastName(lName);
aifEntityKeyList_DirContactPerson = dirContactPersonsService.create(dirContactPersons);
}
}
Before seeing this post please read the post That i posted earlier for creating the vendors.
http://krishhdax.blogspot.dk/2012/03/ax2012-import-vendors-from-csv-using.html
This post is just upgrade of my earlier logic to create vendor,multiple contacts informations.
public static void CreateVendor()
{
VendVendTableService vendVendTableService;
VendVendTable vendVendTable;
VendVendTable_VendTable vendTable;
VendVendTable_DirPartyPostalAddressView adresss;
VendVendTable_DirPartyTable_DirOrganiza1 dirPartyTable;
VendVendTable_DirPartyContactInfoView contactInfoPhone, contactInfoFax, contactInfoEmail,
contactInfoWeb;
VendVendTable_OrganizationName organizationName;
DirContactPersonsService dirContactPersonsService;
DirContactPersons dirContactPersons;
DirContactPersons_ContactPerson dirContactPersons_ContactPerson;
DirContactPersons_Person dirContactPersons_Person;
DirContactPersons_PersonName dirContactPersons_PersonName;
TaxVATNumTable taxVATNumTable;
LogisticsLocationRole logisticsLocationRole =
LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Business);
AifDimensionAttributeValueSet aifDimensionAttributeValueSet;
AifDimensionAttributeValue aifDimensionAttributeValue;
AifEntityKeyList aifEntityKeyList, aifEntityKeyList_DirContactPerson;
str fName, mName, lName;
;
vendVendTableService = vendVendTableService::construct();
vendVendTable = new VendVendTable();
vendTable = vendVendTable.createVendTable().addNew();
vendTable.parmAccountNum(vendorAccount);
vendTable.parmItemBuyerGroupId(buyerGroup);
vendTable.parmVendGroup(credGroup);
vendTable.parmCurrency(currency);
vendTable.parmName(name);
vendTable.parmVATNum(vATNum);
vendTable.parmPaymTermId(PaymTerms);
//This is validated and not found in Ax so update vendor after create or leave empty
vendTable.parmInvoiceAccount(InvoiceAccount);
vendTable.parmDlvTerm(deliveryTerms);
// Create dimension
if (defDimProject)
{
if (!aifDimensionAttributeValueSet)
{
aifDimensionAttributeValueSet = vendTable.createDefaultDimension();
aifDimensionAttributeValue = aifDimensionAttributeValueSet.createValues().addNew();
}
else
{
aifDimensionAttributeValue = aifDimensionAttributeValueSet.parmValues().addNew();
}
aifDimensionAttributeValue.parmName("Project");
aifDimensionAttributeValue.parmValue(defDimProject);
}
if (defDimDepartment)
{
if (!aifDimensionAttributeValueSet)
{
aifDimensionAttributeValueSet = vendTable.createDefaultDimension();
aifDimensionAttributeValue = aifDimensionAttributeValueSet.createValues().addNew();
}
else
{
aifDimensionAttributeValue = aifDimensionAttributeValueSet.parmValues().addNew();
}
aifDimensionAttributeValue.parmName("Department");
aifDimensionAttributeValue.parmValue(defDimDepartment);
}
if (vATNum && !TaxVATNumTable::exist(vendTable.parmVATNum(), countryRegionId))
{
taxVATNumTable.VATNum = vendTable.parmVATNum();
taxVATNumTable.CountryRegionId = countryRegionId;
taxVATNumTable.insert();
}
dirPartyTable = new VendVendTable_DirPartyTable_DirOrganiza1();
vendTable.createDirPartyTable().add(dirPartyTable);
dirPartyTable.parmLanguageId(language);
organizationName = dirPartyTable.createOrganizationName().addNew();
organizationName.parmName(name);
adresss = dirPartyTable.createDirPartyPostalAddressView().addNew();
adresss.parmCity(city);
adresss.parmCountryRegionId(countryRegionId);
adresss.parmStreet(street);
adresss.parmZipCode(zipCode);
adresss.parmRoles(logisticsLocationRole.Name);
contactInfoPhone = dirPartyTable.createDirPartyContactInfoView().addNew();
contactInfoPhone.parmLocationName(name);
contactInfoPhone.parmIsPrimary(NoYes::Yes);
contactInfoPhone.parmLocator(phone);
contactInfoPhone.parmType(LogisticsElectronicAddressMethodType::Phone);
contactInfoPhone.parmRoles(logisticsLocationRole.Name);
contactInfoPhone.parmIsLocationOwner(1);
contactInfoFax = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoFax.parmLocationName(name);
contactInfoFax.parmIsPrimary(NoYes::Yes);
contactInfoFax.parmLocator(fax);
contactInfoFax.parmType(LogisticsElectronicAddressMethodType::Fax);
contactInfoFax.parmRoles(logisticsLocationRole.Name);
contactInfoFax.parmIsLocationOwner(1);
contactInfoEmail = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoEmail.parmLocationName(name);
contactInfoEmail.parmIsPrimary(NoYes::Yes);
contactInfoEmail.parmLocator(email);
contactInfoEmail.parmType(LogisticsElectronicAddressMethodType::Email);
contactInfoEmail.parmRoles(logisticsLocationRole.Name);
contactInfoEmail.parmIsLocationOwner(1);
contactInfoWeb = dirPartyTable.parmDirPartyContactInfoView().addNew();
contactInfoWeb.parmLocationName(name);
contactInfoWeb.parmIsPrimary(NoYes::Yes);
contactInfoWeb.parmLocator(web);
contactInfoWeb.parmType(LogisticsElectronicAddressMethodType::URL);
contactInfoWeb.parmRoles(logisticsLocationRole.Name);
contactInfoWeb.parmIsLocationOwner(1);
aifEntityKeyList = vendVendTableService.create(vendVendTable);
dirContactPersonsService = DirContactPersonsService::construct();
dirContactPersons = new DirContactPersons();
if (contactId)
{
dirContactPersons_ContactPerson = dirContactPersons.createContactPerson().addNew();
dirContactPersons_ContactPerson.parmContactForPartyVendAccount(vendorAccount);
dirContactPersons_Person = dirContactPersons_ContactPerson.createPerson().addNew();
dirContactPersons_Person.parmNameAlias(contactId);
dirContactPersons_PersonName = dirContactPersons_Person.createPersonName().addNew();
[fName, mName, lName] = DirPerson::splitNameParts(contactId);
dirContactPersons_PersonName.parmFirstName(fName);
dirContactPersons_PersonName.parmMiddleName(mName);
dirContactPersons_PersonName.parmLastName(lName);
aifEntityKeyList_DirContactPerson = dirContactPersonsService.create(dirContactPersons);
}
}
No comments:
Post a Comment
Thanks for visiting my blog,
I will reply for your comment within 48 hours.
Thanks,
krishna.