Posts

Showing posts from September, 2021

Create a zipped file using x++

 This article explains how we can create a zipped file in x++ and allow the file to be downloaded using the browser download. For this example, I am adding a csv file to a zipped archive. First we will need to create a stream with the contents for the csv file. CommaStreamIo streamIO = CommaStreamIo::constructForWrite();   streamIO.writeExp('Id', 'Title'); // These will represent the header of the csv file  streamIO.writeExp('001', 'Science'); // Row 1 streamIO.writeExp('002', 'Nature'); // Row 2 Next, we can generate the csv file contents and add it to a zip archive. // Get the stream System.IO.Stream        stream              = streamIO.getStream(); const str               extensionCsv        = '.csv'; c...

Generate and download a csv file using X++

Within Dynamics 365 HQ we often need to be able to export data as a csv file. This article explains how we can generate a csv file. The following lines of code can be used to create and download a csv file Create a writable stream. CommaStreamIo streamIO = CommaStreamIo::constructForWrite();   streamIO.writeExp('Id', 'Title'); // These will represent the header of the csv file  streamIO.writeExp('001', 'Science'); // Row 1 streamIO.writeExp('002', 'Nature'); // Row 2 // Get the stream System.IO.Stream        stream              = streamIO.getStream(); const str               extensionCsv        = '.csv'; stream.Position = 0; // StreamReader to read as str System.IO.StreamReader...

Creating a batch job with query based filter in D365 back-office

There are often business processes that requires us to run specific operations as a batch process. Dynamics 365 Head quarters (HQ) allows us to be able to periodically execute batch jobs. To create a custom batch job you need to extend the  RunBaseBatch class. The following lines of code show how we can create a simple export job.  class InvoiceExport extends RunBaseBatch {      Query                   query;     QueryRun                invoiceQueryRun; // QueryRun object that will be used to generate data for invoices to be exported.      DialogGroup             dialogGroupSetup; // This is a dialog group.     DialogField      ...

D365 POS extensions - Add extension properties to cart

Within Dynamics 365 for commerce there are often a need to add extension properties to existing objects. Adding extension properties to the cart object is often highly used. To add an extension property to the cart object in POS we can use the existing SaveExtensionPropertiesOnCartClientRequest/SaveExtensionPropertiesOnCartClientResponse pairs in POS to be able to update the cart. The following lines of codes can be used to add a simple boolean extension property to the cart object. var commerceProp = new ProxyEntities.CommercePropertyClass(); commerceProp.Key = "SampleExtProp"; var commercePropValue = new ProxyEntities.CommercePropertyValueClass(); commercePropValue.BooleanValue = true; commerceProp.Value = commercePropValue; let extensionProperties: ProxyEntities.CommercePropertyClass[] = []; extensionProperties.push(commerceProp); this.context.runtime.executeAsync(new SaveExtensionPropertiesOnCartClientRequest<SaveExtensionPropertiesOnCartClientResponse>(extensionPro...

Microsoft DevOps release pipeline

Image
In this article I want to go over how we can setup a simple release pipeline that can be used to automate LCS package deployment. This is a continuation of the previous article which explains how we can create a DevOps build pipeline for retail deployable package .   You will need to have access to DevOps pipelines to be able to complete this. Within DevOps, navigate to Pipelines > Releases Click 'New release pipeline' Select 'Empty job' Choose 'Add an artifact' Select the 'Project' and 'Source (build pipeline)' Update the required details as shown in the example below and click 'Add' Click on the job link Click on the Agent job tile and ensure that you select the correct agent pool and agent specification depending on your build machine configuration. Click the plus icon Choose 'Dynamics Lifecycle Services Asset Upload'. This step will copy your deployable package from the build pipeline artifacts and save it under the LCS ass...