Posts

Showing posts from May, 2019

Composite Data Entity

Image
STEP 1: Create data entity for the header and line table (set the same field as primary key for both tables).             The following data entity, staging table and security is created automatically. STEP 2: Create RowID(integer)   and parent row id (integer) in the header staging table (where the Execution Id and Definition group field, relation, index are automatically created).           STEP 3: Create row id and parent row id fields, create relation for primary key, definition group, execution id.           STEP 4: Create relation in line level data entity (primary key) STEP 5: Create composite data entity By adding new dataset element for header and line entity, then map the relation in the line entity. STEP 6: Front end à Workspaces à Data management In data entities, create new record and enter the   composite entity

Exporting data to Excel through X++ code

             Sometimes we need to export data from Microsoft Dynamics 365 to Excel using x++ code. Through this post can see how to export data from form to excel class SMJ_ExportData {     public static void main( Args args)     {         PurchParmLine   PurchParmLine,PurchParmLineSelect;         PurchParmLine = args.record();         DocuFileSaveResult saveResult = DocuFileSave ::promptForSaveLocation( "@ApplicationPlatform:Testingexcelexport ", "xlsx" , null , "Testing excel export" );         if (saveResult && saveResult.parmAction() != DocuFileSaveAction ::Cancel)         {             saveResult.parmOpenParameters( 'web=1' );             saveResult.parmOpenInNewWindow( false );             System.IO. Stream workbookStream = new System.IO. MemoryStream ();             System.IO. MemoryStream memoryStream = new System.IO. MemoryStream ();                    using ( var package = new Of