• There is a maximum of one Primary Key per table, whereas a table can have several alternate keys. The primary key is usually the type of key that other tables, called child tables, refer to when a foreign key field in those other tables need a relational identifier.

  • For new tables the default is a primary key based on the RecId field , incremented number or a completely meaningless number that is generated by the system surrogate key.

  • Alternate key can be chosen as the Replacement Key of a table that can display on forms instead of a meaningless numeric primary key value. Each table can have a maximum of one replacement key.

  • Natural key has meaning to people. Most replacement keys are natural keys.

  • Relations represents a foreign key.

Thank you for reading!

In Dynamics AX, there is a class called SysQueryRangeUtil that can be utilized in both query ranges and table filters. Using methods from this class allow you to be very precise about what dates you want to use in reports or for filtering your data.

Let’s say you have a report that you always want to run to see orders with shipping dates of the next day. It is possible to do so by using one of the methods from the SysQueryRangeUtil. The use of the letter ‘t’ will work for today’s date, but when you try to add days to it, it doesn’t work in reports. Instead, I will use the currentdate() method and add 1 to it.

All methods & expressions must be surrounded by parentheses as shown below.

Figure 1 – Filtering the requested ship dates in an AX query for tomorrow

Filtering the requested ship dates in an AX query for tomorrow (current day() + 1)

On any form with a grid, you filter your data by pressing Ctrl+G.

If I were to want to see open customer invoices from the last 90 days, I would filter my open customer invoices form and use the method (dayRange(-90,0)). The first number represents how many months backward from this month, and the second represents how many months forward. The same sorts of things can be done for the monthRange(), yearRange(), and dateRange() methods. The best part about this is that you can of course save these filters to create views that you might use on a daily basis.

Figure 2 – Searching the grid for the past 90 days

If you are creating your query ranges in code, these methods can also be utilized whenever you are setting them. Definitely be sure to check out the SysQueryRangeUtil class as there are many more methods to use.

Here is some methods you can use:

currentCustomerAccount()

currentVendorAccount()

currentUserId()

currentDate()

dateRange()

day()

dayRange()

greaterThanDate()

greaterThanUtcDate()

greaterThanUtcNow()

lessthanDate()

lessthanUtcDate()

lessthanUtcNow()

monthRange()

yearRange()

for example:

(dayRange(-30,0)) – Results in a date range for the last 30 days: "26-01-2017".."25-02-2017"

(day(-1)) – Results in yesterday's date: 24-02-2017

(day(0)) – Results in today's date: 25-02-2017

(day(1)) – Results in tomorrow's date: 26-02-2017

(greaterThanDate(2)) – Results in every date after today plus 2: > 27-02-2017

(lessThanDate(-1)) – Results in every date of today minus 1: < 24-02-2017

(monthRange(0,2))  Results in first day till the last day of the month's choosen (0 = current month): "01-02-2017".."30-04-2017"

(yearRange(-1,-1))  Results in first day till the last day of the chosen year: "01-01-2017".."31-12-2017"

Thank you for reading!

  • There is a maximum of one Primary Key per table, whereas a table can have several alternate keys. The primary key is usually the type of key that other tables, called child tables, refer to when a foreign key field in those other tables need a relational identifier.

  • For new tables the default is a primary key based on the RecId field , incremented number or a completely meaningless number that is generated by the system surrogate key.

  • As The RecId data type, surrogate keys exist on a primary key table. As The RefRecId ETD, surrogate foreign keys exist on a foreign key table (Ex: Party field is on CustTable Table).

  • Alternate key can be chosen as the Replacement Key of a table that can display on forms instead of a meaningless numeric primary key value. Each table can have a maximum of one replacement key.

  • Natural key has meaning to people. A set of fields that uniquely identify a record and would have formed the primary key of the table, if not for the existence of a surrogate key.

  • Relations represents a foreign key.

Thank you for reading!

InventSum is needed to recalculate sometimes. We should use InventSumRecalcItem class in Dynamics AX.

InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();

First parameter : ItemId

Second parameter : Show errors

Third parameter : Fix or only check

What if you want to calculate for all items:

InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;

WHILE SELECT InventTable
	WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
	{
		InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
		InventSumRecalcItem.updatenow();
	}

Thank you for reading!

I got this error at version Dynamics 2012 R3 CU9, SQL Server 2014, Windows Server 2012 R2.

Those kind of errors will come when you move report from Dev Server to Live Server, even compilation in DP Class, Query, Contract, table … without any error

AX1004: Reference System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 was not a valid model assembly.

MSB3644: The reference assemblies for framework “.NETFramework,Version=v4.0” were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK

Cause

There is no reference Assemblies Version 4.0 under C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework on Windows Server 2012 R2 (only Version 4.5 it have)

Solution

Copy those Assemblies from your any where (Windows 7,8,10) to Server

Restore and compile again.

Thank you for reading!