Multiple DBs for D365 FO

My project had 2 companies which have different data set though their parent Organization is same. Thus, we had dedicated UAT/PPD/REF machines for each company. Though the developers check in against the same dev branch, in order to test their changes which are company specific, we initially had seperate dev boxes.
Can we have both databases in our SQL and swap it based on the dataset we need.
YES!!!
Create a new DB and name it based on the company dataset. Let`s say AxDB_1. Import the data in this db using import command. Steps given below
  1. In the command prompt , change the path to “cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin”.
  2. SqlPackage.exe /a:import /sf:D:\Exportedbacpac\Backup.bacpac /tsn:devBocName /tdn:TargetDBName /p:CommandTimeout=1200
  3. Usually our existing db name would be AxDB. If you need to use the imported database, rename the original Db and change the imported db to AxDb.
  4. It is not possible to directly rename the db. Commands given below
  5. USE [master];GOALTER DATABASE AxDb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;GOEXEC sp_renamedb N’AxDb’, N’AxDb2′; ALTER DATABASE AxDb2 SET MULTI_USER WITH ROLLBACK IMMEDIATE;
  6. Use the above command to rename AxDb_1 to Axdb.
      7. Reset IIS and now the new db is ready with another dataset.
      If you need to change to AxDb2, use the commands mentioned in 5 and 6.

 

Advertisements
Posted in Uncategorized | Leave a comment

Default value for a field – D365 FO

When I was trying to import data for a standard entity, I had to default value for a customized field.  Instead of over layering , I used the event handler of the method “onDefaultingRow” to set the default value for the field. It worked 🙂

DefaultValue.JPG

Posted in Uncategorized | Leave a comment

onInitialised – Post event handler D365 FO

In D365 FO, there are many event handlers for the standard methods in Ax. There are pre and post event handlers. Pre event handlers are used when our logic is to be executed before the existing one and vice versa for Post event handlers.  Event handlers are extensively used in D365 in order to avoid overlayering .
Scenario: I had a scenario where I had to call the form “SalesLine” from the standard form “Sales Quotation”. There is a reference to QuotationId in SalesLine as a part of my customization.  “Init” method in SalesLine form has a check on arguments which calls this form. So in order to include the above table “SalesTableQuotation” , I created a post event handler of the datasource

Blog_onInitiased

Click this method and copy paste it in the class .

Blog_onInitiased1

 

Blog_onInitiased2

Build and execute the form.

 

Posted in Uncategorized | Leave a comment

Display method D365 FO

This post explains on adding display method to a form.
Let us try adding a display method to a form where a new has been added to the Extension form . Since this is an extension form, a new display method cannot be added directly to this form or table.  In D365 FO, there is a slight difference in creating this . So, whenever there is an extension in D365 FO, in order to implement a process, we create a class first. So as a first step here, we are creating a class , but we use “Final” keyword .
So my class looks like this ;

final public class AESalesQuotationLineTbl_Extension

We need to mention for which object this class has been created. So decorate the class with “ExtensionOf” attribute. In this discussion, I am creating a display method for the table “SalesQuotationLine”.
[ExtensionOf(tableStr(SalesQuotationLine))]
final public class AESalesQuotationLineTbl_Extension
Third step is pretty simple, where we write the display method and the logic .

[ExtensionOf(tableStr(SalesQuotationLine))]

final public class AE_SalesQuotationLineTbl_Extension

{

public static display Qty fulfillmentRemainingQty(SalesQuotationLine _this)

{

//logic

}

Finally add the attribute to cache the display method.

[ExtensionOf(tableStr(SalesQuotationLine))]

final public class AE_SalesQuotationLineTbl_Extension

{

[SysClientCacheDataMethodAttribute(true)]

public static display Qty fulfillmentRemainingQty(SalesQuotationLine _this)

{

//logic

}

 

How do we refer this method in the form?

Please note the property “Cache data method” is set to Yes when the display method is referred.

 

 

Posted in D365 Operations, Dynamics Ax | Tagged | Leave a comment

Delete Cancelled PO – Ax2012/D365 FO

We had a scenario where we were asked to delete cancelled POs from the system. Though it seemed to be a simple task but when the POs had many confirmation versions, we ended up with the error “If previous versions exist, the current document cannot be deleted. “
In order to overcome this error, PO related records are to be deleted from the table PurchTableVersion.
Also note,deleting the corresponding Purchline would end up in a SOFT delete (records are not deleted from the database instead the field “IsDeleted” is set to yes ) . To handle this, delete the records from the table PurchLineHistory.
Deleting a cancelled PO has references in many tables, so the above post is as-is and the above suggestion can be tried in Test or other environments before doing in Prod.

 

 

Posted in Ax 2012, D365 Operations, Uncategorized | Tagged , | Leave a comment

DateTime functions

Latest version of Ax refers to the fields which are of type UtcDateTime . There are situations where we need to find the records for a particular created Date or between from/To datetime fields. In such cases, Global class helps us with the functions:
  • datetobeginUtcDateTime
  • datetoendUtcDateTime
Below code snippet finds the records from the purch table for the given date.
public static void main(Args _args)
{
          date dateToConvert = mkDate(29,8,2017);
date dateToConvertEnd = mkDate(29,8,2017);
        select purchTable where
(purchTable.CreatedDateTime >= Global::datetobeginUtcDateTime(dateToConvert,          DateTimeUtil::getUserPreferredTimeZone()) &&
purchTable.CreatedDateTime < Global::datetoendUtcDateTime(dateToConvertEnd, DateTimeUtil::getUserPreferredTimeZone())) ;
}
Posted in Ax 2012, D365 Operations, Uncategorized | Tagged , | Leave a comment

Move the objects from one model to another – D365 FO

In order to move the objects from one model to another model, we opt to copy -paste from original model`s physical folder to destination model`s folder. This is feasible when we have limited objects. but if the object count is more, this approach is tedious.
So here is another way to move the objects from one model to another.
  1. Open the project which has all the objects.
  2. In the same solution, create another project and set its model to the new one .
  3. Drag and drop the objects from the above project to the new one .
  4. Sync and Rebuild.
  5. Now the objects are ready in new model .
This way our job becomes easy and we can be sure the obejcts are not missed because there are chances of missing the objects when they are moved across physical locations.
Posted in D365 Operations, Uncategorized | Leave a comment