Microsoft_MVP_banner

Accessing the URL of AxUrlMenuItem from AX into EP (Code behind)

Sometimes we need to change/append the URL defined on AXURLMenuitem in Dynamics AX 2012 in order to open different EP pages based on user selection. Here is the code to Create the complete URL in code (based On eb Menu Items)      protected override void OnPreRender(EventArgs e)     {                // Get the URL for the webpage that referenced the current record                AxUrlMenuItem url = new AxUrlMenuItem(“EPSalesTableInfo”);                 // update the hyperlink to point to the URL         hpRecord.NavigateUrl = url.Url.ToString();        // you can use this URL to redirect to any page like        Response.Redirect(url.Url.ToString() + “&variable1=” +  stringvalue);            }

Making string field a custom lookup on user selection

Sometimes we just compile our posts to keep the things at one place so we or someone can get it easily when we in need. This post belongs to the same concept 🙂 Requirement was to filter the records in grid according to the selection of base enum values from a lookup. Easy task 🙂 but then I had to make a string field a custom lookup on selection of first value from base enum and to make it a read only on selection of second value of the base enum. This is what I did; Filter: modified public boolean modified() {     boolean ret;     ret = super();     if(str2enum(enum_variable,this.valueStr()) == enum::firstvalue)     {         stringField.allowEdit(true);         stringField .text(‘ ‘);     }     else     {          stringField .allowEdit(False);          stringField .text(curuserid());                     }     return ret; } StringEdit: StringField // This lookup is populating users  Public void lookup() {     Query                   query = new Query();     QueryBuildDataSource    queryBuildDataSource;     QueryBuildRange         queryBuildRange;     SysTableLookup          sysTableLookup;     ;     //Create an instance of SysTableLookup with the form control passed in     sysTableLookup = SysTableLookup::newParameters(tablenum(UserInfo), this);     //Add the fields to be shown in the lookup form     sysTableLookup.addLookupfield(fieldnum(UserInfo, id), true);     sysTableLookup.addLookupfield(fieldnum(UserInfo, name), false);     //create the query datasource     queryBuildDataSource = query.addDataSource(tablenum(UserInfo));     queryBuildRange = queryBuildDataSource.addRange(fieldnum(UserInfo, Id));     queryBuildRange.value(element.getusers());     //add the query to the lookup form     sysTableLookup.parmQuery(query);     // Perform lookup     sysTableLookup.performFormLookup(); } // Method to get users str 100 getusers() {         str 100                     Users;     ;     While Select UsersTable where  UsersTable .UserId == Curuserid()     {         Select Firstonly SysCompanyUserInfo where SysCompanyUserInfo.EmplId ==  UsersTable.Emplid ;         Users+= SysCompanyUserInfo.UserId +’,’;     }     if(!Users)         Return ‘””‘ ;     Return Users ; }

How to configure and run AX 2012 Hyper-V on Virtualbox

I’ve found an interesting link about how to run AX 2012 VPC on Windows 7 without any need for Windows 2008 Hyper-V server installed on your machine. Configuring and running the AX 2012 Hyper-V image with VirtualBox Step by Step guide Video

.NET business connector to access Dynamics AX from .NET world

Few days before I was struggling to import the huge file data from excel into Dynamics AX as AX COM connector is not much powerful to import huge file data from excel. One of mine friends suggested me to go through .Net business connector to achieve the import functionality more quickly. Here is the link which you can also find useful while integrating AX with different .Net based applications. http://blogs.msdn.com/b/cesardelatorre/archive/2007/07/06/accessing-dynamics-ax-4-0-from-net-using-the-dynamics-ax-net-business-connector.aspx

Microsoft Dynamics AX workflow

I found a comprehensive blog describing the tips and tricks and code samples to implement workflow in your environment.  I will be pleased to share it with all ; http://workflowax.wordpress.com/

Manage, Update & Deploy Workflows in AX 2012

I found a very good video describing how we can manage, update and deploy workflows in AX 2012. This demo is demonstrating how workflow is configured and running in Purchase Requisition Process. Link to video: Manage, Update & Deploy Workflows

Import sales orders from master and details text files

The are many code snippets which you can find easily over the internet to import sales orders from a text file or from excel. The purpose of this post is to share my experience of uploading data into sales order form from two different text files. void ImportSalesOrders() {     Container                  con;     CustTable                 custTable;     SalesTable                salesTable;     SalesLine                  salesLine;     Headers                    headers;     Stock                        details;     num                           newSalesId;     Description                custDescription;          InventTable                inventTable;     InventDim                  inventDim;     InventSiteId               inventSiteId;     InventLocationId         inventLocationId;     CustAccount             custAccount;     real                           itemPrice;     ItemId                       itemId;     InventDim                  frominventDim,ToinventDim;     int                             x,y;     NumberSeq               num;     SysOperationProgress progressbar = new SysOperationProgress();     int i;     ;     progressbar.setCaption(‘Importing Journals’);     progressbar.setAnimation(filenameHeader);     progressbar.setTotal(30000);     for (i = 1; i <= 30000; i++)     {         progressbar.setText(strfmt(“@SYS105740”, i));         progressbar.setCount(i, 1);     }     this.importData();     ttsbegin;     while select headers     {         SalesTable = SalesTable::findDocumentNumber(headers.DocumentNumber);         if(!SalesTable)         {             //create sales table             salesTable.initValue();             num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());             newSalesId = num.num();             if (salesTable::exist(newSalesId))             {                 num.abort();                 throw error(“@SYS23020”);             }             salesTable.SalesId = newSalesId;             num.used();             if(custDescription != “”)             {                 salesTable.SalesName = custDescription;             }             custAccount = headers.CustAccount;             //fetch the customer details from cust table using account no selected from drop-down list             select * from custTable where custTable.AccountNum == custAccount;             salesTable.CustAccount = custTable.AccountNum;             salesTable.InvoiceAccount = custTable.InvoiceAccount;             salesTable.SalesType = SalesType::Sales;             salesTable.SalesStatus = SalesStatus::None;             salesTable.CurrencyCode = custTable.Currency;             salesTable.CustGroup = custTable.CustGroup;             salesTable.DeliveryDateControlType = SalesDeliveryDateControlType::SalesLeadTime;             //Set dates as systemDateTime             salesTable.ReceiptDateRequested = systemdateget();             salesTable.ShippingDateRequested = systemdateget();             salesTable.LanguageId = ‘en-us’;             salesTable.DlvMode = ’10’;             inventSiteId = headers.InventSiteId;             inventLocationId = headers.InventSiteId;             salesTable.InventSiteId = inventSiteId;             salesTable.InventLocationId = inventLocationId;             salesTable.DocumentNumber = headers.DocumentNumber;             //Craete Sales Order             salesTable.insert();             while select details             where headers.DocumentNumber == details.DocumentNumber             {                 salesLine.clear();                 // Create Sales Order Line                 salesLine.SalesId = salesTable.SalesId;                 salesLine.initFromSalesTable(salesTable);                 itemId = details.ItemId;                 salesLine.ItemId = itemId;                 salesLine.SalesUnit = InventTable::find(salesLine.ItemId).salesUnitId();                 select * from inventTable where inventTable.ItemId == salesLine.ItemId;                 salesLine.initFromInventTable(inventTable);                 inventDim.clear();                 inventDim.InventSiteId = inventSiteId;                 inventDim.InventLocationId = inventSiteId;                 salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;                 //Set Qty as 1 by default                 salesLine.SalesQty = details.Qty;                 salesLine.ConfirmedDlv = salesTable.ShippingDateConfirmed;                 salesLine.lineNum = SalesLine::lastLineNum(salesLine.salesId) + 1.0;                 salesLine.RemainInventPhysical = 1;                 salesLine.RemainSalesPhysical = 1;                 salesLine.DlvMode = ’10’;                 salesLine.SalesStatus = SalesStatus::None;                 salesLine.SalesPrice = details.UnitPrice;                 salesLine.LineAmount = salesLine.SalesQty * salesLine.SalesPrice;                 //Insert sales line items    

Dynamics AX and database synchronization error

Due to huge customization in application we may come across database and application synchronization failure issue. Sometimes you will see this error when you add some new fields in CustTable or SalesTable, this is just for an example you can have this issue in any table or view. Following job will forcefully synchronize all the tables in AOT. static void forceDbSynchronize(Args _args) {     Dictionary                             dict;     int                                        idx, lastIdx, totalTables;     TableId                                  tableId;     Application                            application;     SysOperationProgress           progress;     StackBase                            errorStack;     ErrorTxt                                 errorTxt;     ;     application = new Application();     dict = new Dictionary();     totalTables = dict.tableCnt();     progress = new SysOperationProgress();     progress.setTotal(totalTables);     progress.setCaption(“@SYS90206”);     errorStack = new StackBase(Types::String);     lastIdx = 0;     try     {         for (idx = lastIdx+1; idx <= totalTables; idx++)         {             tableId = dict.tableCnt2Id(idx);             progress.setText(dict.tableName(tableId));             lastIdx = idx;             application.dbSynchronize(tableId, false, true, false);             progress.incCount();         }     }     catch (Exception::Error)     {         errorTxt = strFmt(“Error in table ‘%1’ (%2)”, tableId, dict.tableName(tableId));         errorStack.push(errorTxt);         retry;     }     setPrefix(“@SYS86407”);     errorTxt = errorStack.pop();     while (errorTxt)     {         error(errorTxt);         errorTxt = errorStack.pop();     }     info(‘Sychrnonization is now done.’); }

FaisalFareed@2025. All rights reserved

Design by T3chDesigns