Question

I have a very simple view in AX 2012. It has one data source, and returns only one row from that table. The view has an Order By DESC specified on the same field that is being returned. There is no Group By clause.

It returns about the first 2/3 of the records in alphabetical order, then the last 2/3 also in alphabetical order, but starting over at A.

The results look something like this:

Apple,Banana,Cherry,Fig,Pear,Plum,Squash,Yam,Apricot,Blueberry,Zucchini

Tried Synchronize, Compile, CIL compile already. Tried dumping the data source and starting over. Pretty much out of ideas.

Jan: here is the View from SQL. Looks like even after I synchronize, the ORDER BY is left out.

USE [MicrosoftDynamicsAX]
GO
/****** Object:  View [dbo].[MENUSVIEW]    Script Date: 03/28/2014 09:57:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[MENUSVIEW] AS SELECT T1.TRANSACTIONNAME AS TRANSACTIONNAME,T1.PARTITION AS PARTITION,T1.RECID AS RECID FROM TRANSACTIONS T1
GO
Was it helpful?

Solution

No idea why this was necessary, and would still like to understand, but here is the workaround I used, by adding it to my form's datasource.

public void init()
{
    super();
    //manually sort the view, because the built in sort does not work
    ScanWorkX_MenusPickerView_ds.query().dataSourceNo(1).sortClear();
    ScanWorkX_MenusPickerView_ds.query().dataSourceNo(1).addSortField(fieldNum(MenusView,
        TransactionName), SortOrder::Ascending);
}

OTHER TIPS

The MSDN documentation on View Basics notes this:

Do not specify a field in the Order By element. A view cannot use the field information in the Order By element.

Which is very odd, considering there are vanilla views which have fields in the Order By element. An example is AssetInsurance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top