web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

X++ job to import vendor contact details from csv file.

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Following job can be used to import vendor contact details (if there are blank) from csv file.

Input format:

VendorContact.jpg_2D00_320x240.jpg

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);
                }
            }
        }
    }
}


Comments

*This post is locked for comments