Posts

Showing posts from January, 2016

X++ code to Count Records in Query

X++ code to Count Records in Query Following code illustrates how we can use  SysQuery::countTotal()   method to get the number of records in Query. static void Query_cntRecords(Args _args) {     Query                query = new Query();     QueryRun             queryRun;     QueryBuildDataSource qbd;     ;          qbd = query.addDataSource(tablenum(CustTable));     queryRun = new QueryRun(query);          info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun)));      }

SSRS Report print in Sales Order Language not in User Language

The objective is to print the transport note report in the Language of Sales Order other than the User's language ,for this purpose overide the Controller "prePromptModifyContract()" method and write the Following Code: protected void prePromptModifyContract() {     STMTransportNote    stmTransportNote;     SalesTable                  salesTable;     super();     if (this.parmArgs() && this.parmArgs().record() is STMTransportNote)     {     stmTransportNote = this.parmArgs().record() as STMTransportNote;     salesTable = SalesTable::find(SalesLine::findRecId(STMTransportNote.SalesLine).SalesId);     this.parmReportContract().parmRdlContract().parmLanguageId(salesTable.LanguageId);    } }

Add Group By Field in Code Using X++

Image
AX 2012 Example of Adding Grouping on DataSource fields using X++: *********************************************************************************** element.inventDimSetupObject().modifyQueryWithBatch(inventSum_DS,inventDim_DS,inventBatch_ds); *********************************************************************************** X++ Code: /// <summary> /// Adds grouping and summing fields for the data sources specified. /// </summary> /// <param name="_inventSum_DS"> /// The data source for the <c>InventSum</c> table. /// </param> /// <param name="_inventDim_DS"> /// The data source for the <c>InventDim</c> table. /// </param> /// <param name="_inventBatch_DS"> /// The data source for the <c>InventBatch</c> table. /// </param> public void modifyQueryWithBatch(     FormDataSource _inventSum_DS,     FormDataSource _inventDim_DS,     FormDataSource _i

Applying grouping to Form DataSource through X++

Image
I had a requirement at client which was related to the Shelf Advice Form: AOT form name: PdsInventBatchShelfAdvice Navigation:   Inventory Management > Inquiries > Batches > Shelf advice as of date Fields to be added :  Field                                      System name Product name*                      (EcoResProductTranslation.name) Expiration date                     (InventBatch.expDate) * adding this field requires a new data source. The required functionality was : ·          Filtering and sorting by grid should be enabled for Expiration date and Product name columns. Therefore option of display method is not acceptable. In the case of Product Name, the relation exists for EcoresProductTranslation with EcoResProduct table; and  EcoresProduct Table with InventTabe , but simply adding the datasources to the form and  adding fields to the grid was not enough because the groupping is being applied to the form data source at initializat

How to enable trace flag 4199 (in SQL server)

How to enable trace flag 4199 You can enable trace flag 4199 at startup or in a user session. This trace flag has either global-level or session-level effect. To enable trace flag 4199, use the  DBCC TRACEON  command or use  –T 4199  as a startup parameter. If  DBCC TRACEON\TRACEOFF  is used this does not regenerate a new cached plan for stored procedures. Plans could be in cache that were created without the trace flag. Reference :  https://support.microsoft.com/en-us/kb/974006

DMFEntity issue : Entity query version '*' is not matching with AOT version '*'

Sometimes we get an error on DMF Entity that query version is not matching with AOT version, To fix this issue we can update our Entity QueryVersion With respect to AOT QueryVersion . Job to update Query Version: static void GTE_DMFQueryVersionUpdateJob(Args _args) {     DMFentity entity;     int a = 0;     #AOT     #define.Version('Version')      TreeNode        treeNode;     ttsBegin;     while select forUpdate entity     {         if (entity.EntityType == DMFEntityTypes::Entity)            {                treeNode = treeNode::findNode(#QueriesPath + #AOTDelimiter + entity .TargetEntity);                if (treeNode)                {                    entity .QueryVersion = treeNode.AOTgetProperty(#Version);                }                 entity.doupdate();                a++;            }     }     ttsCommit;     info(int2str(a));  //NO# of Updated Records }

Uninstall a model IN AX 2012

Uninstall a model (Windows PowerShell) On the  Start  menu, point to  All Programs , point to  Administrative Tools , and then click  Microsoft Dynamics AX Management Shell . At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER. Windows PowerShell Uninstall - AXModel - Model <Modelname > This command uninstalls the specified model. By default, a confirmation request is displayed. List models (Windows PowerShell) To list the models in a layer, at the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER. Windows PowerShell Get - AXModel - Layer <LayerName > To list the models in the model store, at the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER. Get-AXModel