X++ job to import vendor contact details from csv file.
Views (7815)
Following job can be used to import vendor contact details (if there are blank) from csv file.
Input format:
static void uploadVendorDetails(Args _args)
{
CommaTextIO csvFile;
container readCon;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
VendTable vendTable;
DirParty dirParty;
DirPartyRecId partyRecId;
AccountNum accountNum;
DirPartyContactInfoView contactView;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(['csv','*.csv']);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
accountNum = conPeek(readCon,1);
vendTable = vendTable::find(conPeek(readCon,1));
partyRecId = vendTable.Party;
DirParty = DirParty::constructFromPartyRecId(partyRecId);
select contactView
where contactView.Party == vendTable.Party
&& contactView.Type == LogisticsElectronicAddressMethodType::Phone;
// Phone description and Phone number
if ((contactView.RecId == 0) && (conPeek(readCon,2) != "")) // Please comment this condition, if not required
{
contactView.LocationName = "Phone Number"; // Phone description
contactView.Locator = strLRTrim(conPeek(readCon,3)); // Phone Number
contactView.Type = LogisticsElectronicAddressMethodType::Phone;
contactView.Party = partyRecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
select contactView
where contactView.Party == vendTable.Party
&& contactView.Type == LogisticsElectronicAddressMethodType::Email;
// Email name and emailId
if ((contactView.RecId == 0) && (conPeek(readCon,4) != "")) // Please comment this condition, if not required
{
contactView.LocationName = "Email"; // Email description
contactView.Locator = strLRTrim(conPeek(readCon, 5)); // EmailId
contactView.Type = LogisticsElectronicAddressMethodType::Email;
contactView.Party = partyRecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
select contactView
where contactView.Party == vendTable.Party
&& contactView.Type == LogisticsElectronicAddressMethodType::URL;
// URL description and URL
if ((contactView.RecId == 0) && (conPeek(readCon,6) != "")) // Please comment this condition, if not required
{
contactView.LocationName = "URL"; // URl Description
contactView.Locator = strLRTrim(conPeek(readCon,7)); // URL
contactView.Type = LogisticsElectronicAddressMethodType::URL;
contactView.Party = partyRecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
select contactView
where contactView.Party == vendTable.Party
&& contactView.Type == LogisticsElectronicAddressMethodType::Fax;
// Fax description and Fax number
if ((contactView.RecId == 0) && (conPeek(readCon,8) != "")) // Please comment this condition, if not required
{
contactView.LocationName = "Fax"; // Fax Description
contactView.Locator = strLRTrim(conPeek(readCon,9)); // Fax description
contactView.Type = LogisticsElectronicAddressMethodType::Fax;
contactView.Party = partyRecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
}
}
}
}

Like
Report
*This post is locked for comments