web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Behind AX / AX 2012 - Add computed colu...

AX 2012 - Add computed column to view.

metin emre Profile Picture metin emre 502
When we add a computed column to AX view what we do actually is adding extra keywords to SQL Server view without any errors.

First we add a table method to AX view:

public static server str SNBisBuggedReverse()
{
return strFmt("select top 1 sign(sum(accountingcurrencyamount)) from GENERALJOURNALACCOUNTENTRY g "+
"where isnull(%1,'') <> '' and exists (select * from TRANSACTIONREVERSALTRANS t where t.TRACENUM = %1 and t.REFRECID = g.RECID and t.REFTABLEID = %2) "+
"group by g.LEDGERACCOUNT "+
"order by 1 desc",SysComputedColumn::comparisonField(identifierstr(PAXMizanView), identifierstr(TransactionReversalTrans), identifierstr(TraceNum)),
 tableNum(GeneralJournalAccountEntry));
}

Seem at up we just use SQL Server query keywords, not AX. Our method will return a string like that:

select top 1 sign(sum(accountingcurrencyamount)) from GENERALJOURNALACCOUNTENTRY g where isnull(T4.TRACENUM,'') <> '' and exists (select * from TRANSACTIONREVERSALTRANS t where t.TRACENUM = T4.TRACENUM and t.REFRECID = g.RECID and t.REFTABLEID = 3119) group by g.LEDGERACCOUNT order by 1 desc

We want to add an Enum field as type NoYes. Than:




After that we select our table methods name from ViewMethod property:




My computed column was unfortunately made my view so slow, we should faster things as possible as we could for create a fast view.

This was originally posted here.

Comments

*This post is locked for comments