Dynamics 365 Business Central: handling BLOB fields on APIs

I’m not a big fan of using BLOB fields on the Dynamics 365 Business Central database, but there are many scenarios where you need to handle BLOBs inside the database directly.

As an example, imagine to have an application that handles different types of labels related to items and these labels are stored inside the Dynamics 365 Business Central database in a table called Labels. This table is defined as following:

Source : Stefano Demiliani
Read more…

Using Memo BLOB to Enable Huge Text

Generally speaking, enabling huge text fields in NAV is bad design because it encourages dumping unstructured data into the system. Reason Codes is an example of adding useful, structured data to the system.

But, every once in a while, there’s a legitimate need to write up a large chunk of text. The Notes functionality isn’t bad for that, but try adding that to a Report or a FastTab.

Bron : The Second Self of Jeremy Vyska
Lees meer…

Writing to a blob: heads up

Recently I was creating a function to resize an image. The function itself was resizing the image perfectly, however, my file size was always at least the same size…

I think I tried about 8 different pieces of DotNet code, always resulting in the same thing. The image was resized, but the file size was at least the same as the original.

Bron : Magno’s Blog
Lees meer…

Display Text from a Blob Field in RDLC Report

If you want to display text that is stored in binary format in a report you would need to use looping and reading the content of the blob piece for piece.

With .net Interop we can do this a lot better. The StreamReader class is ideal to handle this. It is capable to read the text inside the blob, detects the correct charset and gives us back the whole content with one method call.

Bron : deV.ch – man vs. code
Lees meer…

Create any graph in NAV using Excel

Variables
ExcelApp Automation ‘Microsoft Excel 15.0 Object Library’.Application
ExcelBook Automation ‘Microsoft Excel 15.0 Object Library’.Workbook
ExcelSheet Automation ‘Microsoft Excel 15.0 Object Library’.Worksheet
ExcelRange Automation ‘Microsoft Excel 15.0 Object Library’.Range
ExcelChart Automation ‘Microsoft Excel 15.0 Object Library’.Chart
GraphFile File
MemStream InStream
OStream OutStream
Customer Record Customer

CREATE(ExcelApp, FALSE, TRUE);

ExcelBook := ExcelApp.Workbooks.Add(-4167);
ExcelSheet := ExcelApp.ActiveSheet;
ExcelSheet.Name := ‘Sales customer’;

Customer.SETFILTER(“Date Filter”,’%1..%2′,010112D,311212D);
Customer.CALCFIELDS(“Sales (LCY)”);
ExcelSheet.Range(‘A1’).Value := ‘2012’;
ExcelSheet.Range(‘A2′).Value := Customer.”Sales (LCY)”;

Customer.SETFILTER(“Date Filter”,’%1..%2’,010113D,311213D);
Customer.CALCFIELDS(“Sales (LCY)”);
ExcelSheet.Range(‘B1’).Value := ‘2013’;
ExcelSheet.Range(‘B2′).Value := Customer.”Sales (LCY)”;

Customer.SETFILTER(“Date Filter”,’%1..%2’,010114D,311214D);
Customer.CALCFIELDS(“Sales (LCY)”);
ExcelSheet.Range(‘C1’).Value := ‘2014’;
ExcelSheet.Range(‘C2’).Value := Customer.”Sales (LCY)”;

ExcelRange := ExcelSheet.Range(‘A1:C2’);
ExcelChart := ExcelBook.Charts.Add;
ExcelChart.Name := ‘Customergraph’;

ExcelChart.ChartWizard(ExcelRange,60,70,1,1,0,0,’Sales (LCY) Customer Pardaan Inc.’);
ExcelChart.Export(TEMPORARYPATH+’graph.png’);

GraphFile.OPEN(TEMPORARYPATH+’graph.png’);
GraphFile.CREATEINSTREAM(MemStream);
CALCFIELDS(Graph);
Graph.CREATEOUTSTREAM(OStream);
COPYSTREAM(OStream,MemStream);
MODIFY;
GraphFile.CLOSE;

Download objects (NAV 2009 R2) : [download id=”133″]

Parameters ChartWizard Method
ChartType enumeration

graph