Posts

Valid Time State/Date Effective Framework

Image
D365 features a new framework called the date effective framework, or valid time state tables. There are many easy examples of date effective data. The easy example is some sort of rate table, where rates become effective and expire at certain times. Other examples could be bills of material or revisions of items that become effective or expire at certain dates. Date effective comes in two flavors. One uses regular date fields, the other UtcDateTime data type. Obviously, the UtcDateTime gives you more granularity to the second (and the nice timezone support that comes with UtcDatetime). For this example, we'll just stick with an easy example using regular dates. First, we create a new table and we'll call it LeaveRequest table. We'll give the table a LeaveRequestID field which identifies the different request ID. On the table's properties, we'll set the ValidTimeStateFieldType to "Date". This will automatically create two new date fields called "

Filter the data in between two dates

public void executeQuery() {    QueryBuildRange datefilter;    datefilter = this .query().dataSourceNo( 1 ).addRange( fieldNum ( LeaveRequestHeader ,RequestDate));    datefilter.value(queryRange( 26\07\2019 , 29\07\2019 ));        super (); }

Importing data from Excel through X++ code

  Sometimes we need to import data from  Excel to  Microsoft Dynamics 365 form  using x++ code. Through this post can see how to import a data from  excel to  form Public static class ImportLeaveRequestLine {     public static void main( Args _args)     {         System.IO. Stream stream;         LeaveRequestHeader LeaveRequestHeader = _args.record();         LeaveRequestLine    LeaveRequestLine;         ExcelSpreadsheetName sheeet;         FileUploadBuild fileUpload;         DialogGroup dlgUploadGroup;         FileUploadBuild fileUploadBuild;         FormBuildControl formBuildControl;         Dialog dialog = new Dialog ( "Import the leave details" );         ;         dlgUploadGroup = dialog.addGroup( "Select excel file" );         formBuildControl = dialog.formBuildDesign().control(dlgUploadGroup.name());         fileUploadBuild = formBuildControl.addControlEx( classstr ( FileUpload ), 'Upload' );   

Custom Workflow Development for Existing Forms

Image
                canSubmitToWorkflow is not working at all in D365FO extensions, but we can achieve this by creating custom workflow with new table which we will use sort of extension and associate the table with standard form extension. Following are the steps to create custom work flow and associate with existing form. Here I am created workflow for service order form this is located in service management module. Step-1 –  Create custom Enum or you can use existing.          Step-2 –  Create custom table (Table name: SMJ_ServiceOrderWorkflow) and add two fields Main field id and Status field extend both fields with appropriate Enum or EDTs. 1)       Main field is ServiceOrderID 2)       Status field is WorkflowStatus Step-3 –  Create relation on parent table and our newly created table on the basis of Main field id. Step-4 –  Create a Custom Query (Query name: SMJ_ServiceOrderWF) and     Add the newly created table

Create a Simple Approval Workflow in Microsoft Dynamics D365

Image
Step 1: Basing on the requirement create a new base enum or use the existing base enum Step 2:           Create new fields to your main table – Ex:  SMJ_PurchaseOrder •        Status – Enum Type -  SMJ_Workflow •        SubmittedBy – Edt  –  UserId •        SubmittedDateTime – Edt  –  DateSubmitted Set the properties for the above 3 fields  AllowEditOnCreate – No AllowEdit – No   Step 3: Add table level methods 1.                     Override the Method in the Main table– canSubmitToWorkflow 2.                     Create a new method (Not overridden method) in the main table as below. Below is the code: Override the Method in the Main table– canSubmitToWorkflow /// <returns></returns>     public boolean canSubmitToWorkflow( str _workflowType = '' )     {         boolean ret;         SMJ_PurchaseOrder     SMJ_PurchaseOrder;         select firstOnly SMJ_PurchaseOrder where SMJ_PurchaseOrder.P