Get Form Control on Any form – Dynamics 365 for Finance and Operations – X++

To get any form control on any form use below method. Create this method as static and use anywhere in your code.

 

Just need to provide FormRun and control name as parameters

 

Public Static FormControl getFormControl(FormRun _formRun, str _controlName)

    {

        FormControl control = _formRun.control(_formRun.controlId(_controlName));

        Debug::assert(control != null);

        

        return control;

    }

FormDataSource field eventHandlers – Microsoft Dynamics 365 For finance and Operations – D365 FnO Event Handlers

Scenario: Sometime we need to use the form datasource field events to validate or modify the data.

In below code we are updating the data of one field based on modifying the data on the other field

Screen Shot 2019-10-23 at 10.48.34 AM.png

 

Code:

    /// <summary>

    ///

    /// </summary>

    /// <param name=”sender”></param>

    /// <param name=”e”></param>

    [FormDataFieldEventHandler(formDataFieldStr(HcmTopicCreate, HcmTopic, Title), FormDataFieldEventType::Modified)]

    public static void Title_OnModified(FormDataObject sender, FormDataFieldEventArgs e)

    {

        HcmTopic hcmTopic = sender.datasource().cursor();

        HcmSkill hcmSkill = HcmSkill::findBySkill(hcmTopic.Title);

        hcmTopic.Description = hcmSkill.Description;

    }

What’s new or changed in Finance and Operations apps version 10.0.6 (November 2019)

Below are summary about the new update of Microsoft Dynamics Finance and Operations apps version 10.0.6

  1. Product Configuration models V2 data entity(2nd version)
  2. Feature Management Enhancements
    • By default not all features are enable
  3. Project contract committed details
    • Now user can drill-down into the details of the committed amount on the funding source
  4. Purchase agreement responsible party
    • Now user can define primary and secondary responsible party on the purchase agreement classification form and resulting purchase agreement
  5. RFQ Link on the Purchase order line
    • Now a reference link can be add from the purchase order line back to the corresponding RFQ lines they originated from

 

For more details visit Microsoft Documentation using below link

 

Whats changed in 10.0.6

 

Temp table(InMemory) buffer usage in the same instance – Microsoft Dynamics 365 for Finance and Operations – Ax2012 – X++

Scenario: Sometime you have to use InMemory table buffer to apply some logic within the same buffer.

Solution: The solution is to use the sameTable variable by using SetTempData

 

//local variable

TempTable localTempTable;

;

// set the data to the local tmp table from the original tmp table

localTempTable.setTmpData(originalTmpTable);

ttsbegin;

while select forupdate localTempTable //where localTempTable.somecoindtion ==

{

localTempTable.someField = ”;

localTempTable.update();

}

ttscommit;

//at the end  after completing the loop set the tmp data back to the original tmp data

originalTmpTable.setTmpData(localTempTable);

 

 

 

Sandbox UAT SQL server database access – Microsoft Dynamics 365 for Finance and Operations

Scenario: Accessing of Microsoft Dynamics 365 for Finance and Operations database on sandbox environment.

In August 2019 Microsoft did the database scaling and migration in different regions. so might be your Dynamics 365 for Finance and Operations might be changed. When you trying to logon you will face some difficulty.

Below are the steps to access the new sql server and database.

  • Copy the SQL server name from LCS and put on logon screen

Example: spartan-tes-nam-d365tessst-test123456.database.windows.net

Screen Shot 2019-10-15 at 10.33.13 AM.png

 

  • After adding above information click on options

Screen Shot 2019-10-15 at 10.36.43 AM.png

 

  • Copy the database name(below screenshot before AXDB) from the LCS environment and paste in the connect to database field as per above screenshot

Screen Shot 2019-10-15 at 10.37.41 AM.png

 

  • Click on connect and now you are successfully able to connect

 

Note: Please leave comments if you are facing any issue by following the above steps.

delete_from in X++ Ax2012/ D365 F&O – Dynamics 365 For Finance and Operations

Scenario: Delete all record from table at once based on some condition.

Code:

//declare table varibale

MyTable  myTable;

 

ttsbegin;

// to delete all records with any condition

delete_from myTable;

or

//delete records based on some condition

delete_from myTable where mytable.Recid = 12345677;

 

ttscommit;

Unable to connect to Azure Storage )Local VM)- Dynamics 365 for Finance and Operations

Issue:

Unable to connect to the remote server at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)at Microsoft.WindowsAzure.Storage.Table.CloudTable.Exists(Boolean primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.DynamicsOnline.Infrastructure.Components.TableAccessor.TableStorageAccessor.PerformOperation(CloudStorageAccount storageAccount, String tableName, Func`1 operation) at Microsoft.DynamicsOnline.Infrastructure.Components.TableAccessor.TableStorageAccessor.AddRecord[T](CloudStorageAccount storageAccount, String tableName, T record) at

Reason:

This issue is coming because Azure emulator is not running.

Resolution:

Issue can be checked and resolved using below commands.

Screen Shot 2019-09-30 at 6.57.04 PM

Get Next Number sequence thru code X++ – Microsoft Dynamics 365 For Finance and Operations

Scenario: Normally next number sequence is created when new record create from the front end but sometimes we need to create next number sequence from code when importing the records thru code

Solution: Below code will be used to get next number sequence

 

NumberSeq::newGetNum(Number Sequence reference as parameter).num();

Parameters details:

NumberSequenceReference _numberSequenceReference, mandatory

        boolean                 _makeDecisionLater          = false, optional

        boolean                 _dontThrowOnMissingRefSetUp = false optional

        //<GEERU><GEEU>

        ,UnknownNoYes            _allowManual                = UnknownNoYes::Unknown optional

Simple Dialog using X++ – Dynamics 365 for Finance and Operations

Scenario: Sometimes we need a simple dialog having some fields and we do not want to use dialog form ,instead of that we can create dialog thru X++ code.

Below is the code you can use to create simple dialog.

Example Code:

      

//Declare dialog variables       

Dialog                  dialog;       

DialogField             fieldfDate, fieldtDate;       

FromDate _fromDate, _toDate;       

;       

dialog = new Dialog(“Select start and end date”);       

//define fields to show on the dialog       

fieldfDate = dialog.addField(extendedTypeStr(TransDate));       

fieldtDate = dialog.addField(extendedTypeStr(TransDate));              

dialog.run();       

if (dialog.closedOk())       

{

           //get values from the dialog fields

            _fromDate = fieldfDate.value();

            _toDate = fieldtDate.value();   

}

Introduction to Form Patterns – Dynamics 365 for Finance and Operations

Form Patterns are introduced in Dynamics 365 for Finance and Operations, In Dynamics AX2012 we used form styles. These Patterns provide a base structure based on particular style (including required and optional controls), and also provide many default control properties. Patterns have made the form development very easier and after applying the pattern its validate and give the gurantee to the developers that its correct and consistant.

Patterns help validate form and control structures, and also use of control in some places.Form patterns provide many default control properties, and these also contribute to a more guided development experience.

List of Top Level Form Patterns

Form pattern What it’s used for
Details Master (two variants) A form that displays the details of a complex entity
Details Transaction A form that displays the details of a complex transaction entity and its lines (for example, and order and its lines)
Dialog (six variants) A form that is used as a dialog to gather a set of information
Drop Dialog (two variants) A form that is used as a drop dialog to gather a small set of information to provide context for an action
FactBox (two variants) A Microsoft Dynamics AX 2012 FactBox that displays information about a related record or set of records
List Page A Dynamics AX 2012 List Page
Lookup (three variants) A form that is used as a lookup
Simple Details (four variants) A form that is focused on a single record
Simple List A form that displays details for a simple entity as a grid that has fewer than 10 fields per record
Simple List & Details (three variants) A form that displays information about an entity of medium complexity
Table of Contents A form that displays setup information or loosely related information sets
Task (two variants) A legacy form pattern that is used to display master or transaction entities
Wizard A form that displays a set of tab pages to the user to gather information in a predetermined order
Operational Workspace A form that is used to display an overview of an activity and is meant to be a primary means of navigation
Workspace Panorama Sections (three variants) A form that is used to show content for a panorama section (via a Form Part Control) in the Operational Workspace

 

This is just an introduction of the form patterns will describe each pattern in details in separate post.