Excel addin for D365 and Table browser for Chrome

Below steps will guide you to add D365 excel addin to your Excel

Step 1:

Browse the below link, and Click Add button

https://store.office.com/en-001/app.aspx?assetid=WA104379629&ui=en-US&rs=en-001&ad=US&appredirect=false

D365-1

Step 2:

Click on Open in Excel link

D365-2

Step 3:

Click on Open Office (desktop) as shown in below screenshot

D365-3

Step 4:

It will prompt you a window, as shown in below click yes

D365-4

Step 5:

Excel will be opened and asked for Enable, Click on Enable

D365-5

Step 6:

After clicking the Enable  a window will be opened on right side of excel to login to your D365 account,

D365-6

 

Step 6:

Paste the Same URL in server URL, click on Ok

Login to your D365 account and copy the URL till XXX.dynamics.com

D365-7

D365-8

Step 7:

It will ask you to confirm the changes, on clicking the Yes button it will be redirect you to sign in page

login with your account details which is using for D365

D365-9

 

 

 

 

Advertisements

Import Customer through X++


static void UploadCustomer(Args _args)
{
 CommaTextIO csvFile;
 container readCon;
 counter icount,inserted;
 Dialog dialog;
 DialogField dfFileName;


 FileName fileName;
 Name name;

 DirPartyContactInfoView contactView;
 CustTable CustTable;
 DirParty dirParty;
 DirPartyRecId partyRecId;

 LogisticsPostalAddress address;
 DirPartyPostalAddressView addressView;

 inserted =0;

 #File


 dialog = new Dialog("Pick the file");
 dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
 dialog.filenameLookupFilter(["All files", #AllFiles]);


 if (dialog.run())
 {
 csvFile = new CommaTextIo(dfFileName.value(), 'r');
 csvFile.inFieldDelimiter(',');
 readCon = csvFile.read();
 ttsBegin;
 while(csvFile.status() == IO_Status::OK)
 {
 readCon = csvFile.read();

 if(readCon)
 {
 icount++;

 name = conPeek(readCon,2);
 partyRecId = DirPartyTable::createNew( DirPartyType::Organization, name).RecId;

 custTable.clear();
 custTable.initValue();
 custTable.Party = partyRecId;
 custTable.AccountNum = conPeek(readCon,1);
 custTable.CustGroup = conPeek(readCon,3);
 custTable.Currency = conPeek(readCon,7);
 custTable.DlvMode = conPeek(readCon,8);
 custTable.PaymTermId = conPeek(readCon,9);
 custTable.insert();

 custTable = Custtable::find(conPeek(readCon,1));
 partyRecId = custTable.Party;

 DirParty = DirParty::constructFromPartyRecId(partyRecId );
 address.clear();
 //address.PostBox = strLRTrim(conPeek(readCon,13));
 address.CountryRegionId = strLRTrim(conPeek(readCon,5));
 if( address.CountryRegionId != "")
 {
 address.State = strLRTrim(conPeek(readCon,15));
 address.ZipCode = strLRTrim(conPeek(readCon,15));
 address.Street = strLRTrim(conPeek(readCon,4));
 address.City = strLRTrim(conPeek(readCon,18));
 
 //address.Address = conPeek(readCon,4);
 
 addressView.LocationName = "Address";
 addressView.IsPrimary = NoYes::Yes;
 addressView.Party = partyRecId;
 addressview.initFromPostalAddress(address);


 DirParty = DirParty::constructFromPartyRecId(addressView.Party );
 DirParty.createOrUpdatePostalAddress(addressView);
 }

 contactView.clear();

 if(conPeek(readCon,5) != "")
 {
 contactView.LocationName = "Phone Number";
 contactView.Locator = strLRTrim(conPeek(readCon,5));
 contactView.Type = LogisticsElectronicAddressMethodType::Phone;
 contactView.Party = partyRecId;
 contactView.IsPrimary = NoYes::Yes;
 dirParty.createOrUpdateContactInfo(contactView);
 }

 if(conPeek(readCon,3) != "")
 {
 contactView.LocationName = "Fax Number";
 contactView.Locator = strLRTrim(conPeek(readCon,3));
 contactView.Type = LogisticsElectronicAddressMethodType::Fax;
 contactView.Party = partyRecId;
 contactView.IsPrimary = NoYes::Yes;
 dirParty.createOrUpdateContactInfo(contactView);
 }

 if(conPeek(readCon,4) != "")
 {
 contactView.LocationName = "Website";
 contactView.Locator = strLRTrim(conPeek(readCon,4));
 contactView.Type = LogisticsElectronicAddressMethodType::URL;
 contactView.Party = partyRecId;
 contactView.IsPrimary = NoYes::Yes;
 dirParty.createOrUpdateContactInfo(contactView);
 }

 if(conPeek(readCon,6) != "")
 {
 contactView.LocationName = "Email";
 contactView.Locator = strLRTrim(conPeek(readCon,6));
 contactView.Type = LogisticsElectronicAddressMethodType::Email;
 contactView.Party = partyRecId;
 contactView.IsPrimary = NoYes::Yes;
 dirParty.createOrUpdateContactInfo(contactView);
 }

 }

 }
 ttsCommit;
 }

}

Excel Import with Dialog

static void FixedAssetImport(Args _args)
{
    Num serialnumber;
    AssetTable assetTable;
    AssetId assetId;
    AssetGroupId assetGroupId;
    Dialog dialog;
    Filename filename;
    DialogField dialogFilename;
    //To filter the files while selecting
    container conFilter = ["Microsoft Excel 97-2003 Worksheet (.xls)" ,"*.xlsx"];
    
    //Excel
    SysExcelApplication application;
    SysExcelWorkbooks workbooks;
    SysExcelWorkbook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet;
    SysExcelCells cells;
    COMVariantType type;
    int row=1;
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    dialog = new dialog();
    dialog.caption("select a file");
    dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
    //To filter the files while selecting
    dialog.filenameLookupFilter(conFilter);
    dialog.run();
    
    if(dialog.closedOk())
    {
        filename = dialogFileName.value();
    }
    
    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }
    
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    
    do
    {
        row++;
        assetGroupId = cells.item(row,1).value().bStr();
        assetId = cells.item(row,2).value().bStr();
        serialnumber = cells.item(row,3).value().bStr();
        
        if( assetGroupId && assetId && serialnumber)
        {
            select forupdate AssetGroup,AssetId,Recid from AssetTable
                                    where assetTable.SerialNum == "" &&
                                    assetTable.AssetGroup == assetGroupId &&
                                    assetTable.AssetId == assetId;
        
            if(AssetTable.RecId)
            {
                assetTable.SerialNum = serialnumber ;
                assetTable.update();
            }
            else
            {
                error(strFmt("Please check the values for AssetId:%1",assetId));
            }
            
        }
        else
        {
            error(strFmt("Please check the values for AssetId:%1",assetId));
        }
        
        type = cells.item(row+1, 1).value().variantType();
    }
    while(type != COMVariantType::VT_EMPTY);
    
    workbooks.close();
    application.quit();
    
    info("Operation/Processing Completed");

}

Importing Sales Order & Sales Lines from Excel file

static void MultiSalesOrdersLineImportfromExcel(Args _args)
{
SalesTable      salesTable;
SalesLine       salesLine;
InventDim       inventDim;
NumberSeq        num;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet,worksheet1;
SysExcelCells cells,cells1;
COMVariantType type;
int row;
;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open('C:\\Users\\ax.user01\\Desktop\\SalesOrderCreate.xlsx');
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromName("Header");
worksheet1 = worksheets.itemFromName("Lines");
cells = worksheet.cells();
cells1 = worksheet1.cells();

num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
salesTable.SalesId = num.num();

salesTable.CustAccount = cells.item(1,1).value().bStr();
salesTable.initValue(SalesType::Sales);
salesTable.initFromCustTable();
if(salesTable.validateWrite())
{
salesTable.insert();
}

do
{
row++;
inventDim.clear();
inventDim.InventSiteId = int2str(real2int(cells1.item(row,4).value().double()));
inventDim.InventLocationId = int2str(real2int(cells1.item(row,5).value().double()));

salesLine.clear();
salesLine.initValue(salesTable.SalesType);
salesLine.initFromSalesTable(salesTable);
salesLine.ItemId = cells1.item(row, 1).value().bStr();
salesLine.initFromInventTable(InventTable::find(cells1.item(row, 1).value().bStr()));
salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
salesLine.SalesQty = any2int(cells1.item(row,2).value().toString());
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.SalesUnit = cells1.item(row,3).value().bStr();
salesLine.QtyOrdered = salesLine.calcQtyOrdered();
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId));

type = cells1.item(row+1, 1).value().variantType();
if (salesLine.validateWrite())
{
salesLine.insert();
}
}
while (type != COMVariantType::VT_EMPTY);

workbooks.close();
application.quit();

info("Done!");
}