Contact.SETRANGE(Type, Contact.Type::Person);
CompanyContact.SETRANGE(Type, Contact.Type::Company);
if Contact.FINDSET(false, false) then begin
repeat
//Find Customer/Company
ContactBusiness.SETRANGE("Contact No.", Contact."Company No.");
if ContactBusiness.FINDFIRST then begin
if Customer.GET(ContactBusiness."No.") and (Contact."Company Name" = Customer.Name)
and CompanyContact.GET(Contact."Company No.") then begin
XmlHelper.AddElement(XmlAccessUserChild, 'item', '', '', itemNode);
XmlHelper.AddAttribute(itemNode, 'table', 'AccessUser');
XmlHelper.AddField(itemNode, 'AccessUserUserName', Contact."E-Mail");
XmlHelper.AddField(itemNode, 'AccessUserExternalID', Contact."No.");
XmlHelper.AddField(itemNode, 'AccessUserCustomerNumber', ContactBusiness."No.");
XmlHelper.AddField(itemNode, 'AccessUserName', Contact.Name);
//Use company address
XmlHelper.AddField(itemNode, 'AccessUserEmail', CompanyContact."E-Mail");
XmlHelper.AddField(itemNode, 'AccessUserPhone', Customer."Phone No.");
XmlHelper.AddField(itemNode, 'AccessUserFax', Customer."Fax No.");
XmlHelper.AddField(itemNode, 'AccessUserAddress', Customer.Address);
XmlHelper.AddField(itemNode, 'AccessUserAddress2', Customer."Address 2");
XmlHelper.AddField(itemNode, 'AccessUserZip', Customer."Post Code");
XmlHelper.AddField(itemNode, 'AccessUserCity', Customer.City);
XmlHelper.AddField(itemNode, 'AccessUserCountry', Customer."Country/Region Code");
XmlHelper.AddField(itemNode, 'AccessUserAddressTitle', 'Company address');
XmlHelper.AddField(itemNode, 'AccessUserCompany', Contact."Company Name");
//
if Customer."Currency Code" <> '' then
XmlHelper.AddField(itemNode, 'AccessUserCurrencyCharacter', Customer."Currency Code")
else
XmlHelper.AddField(itemNode, 'AccessUserCurrencyCharacter', glsetup."LCY Code");
XmlHelper.AddField(itemNode, 'AccessUserActive', 'true');
XmlHelper.AddField(itemNode, 'AccessUserWeb', Contact."Home Page");
XmlHelper.AddField(itemNode, 'AccessUserGroups', 'Customers');
UsersPublisher.OnAddContactXmlNode(itemNode, Contact, Customer);
end else begin
//Do not import Contact that doesn't belong to any Customer
end;
end;
until Contact.NEXT = 0;
end;
Kind regards, Dmitrij