Skip to main content

Posts

Showing posts from March, 2023

X++ code to create FreeText Invoice and post in Ax 2012

 First insert in header table like this.         custInvoiceTable.clear();         custInvoiceTable.initFromCustTable(custtable);                 custInvoiceTable.insert(); Then Insert in invoice line table. custInvoiceLine.clear();             custInvoiceLine.initValue();                          //setup main account as required              offsetDimensions = ["3434","3434", 0, "", ""]; // you can set a Main Account with multiple financial dimensions             custInvoiceLine.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(offsetDimensions);             custInvoiceLine.initFromCustInvoiceTable(custInvoiceTable);             custInvoiceLine.ItemId = "erw234324"; //custom field...

X++ code to find all menu items related to form in Axapta

 Below code to find all menu items related to form in Axapta. You can try in Job in AOT. Thanks #AOT str find = “PurchTable”; TreeNode root = TreeNode::findNode(#MenuItemsDisplayPath); TreeNode current; TreeNodeTraverser trav = new TreeNodeTraverser(root,false); current = trav.next(); while (current) { if ((current.AOTgetProperty(‘ObjectType’) == “Form”) && (current.AOTgetProperty(‘Object’) == find)) info(strFmt(“Found menuitem %1”,current.AOTname())); current = trav.next(); }

get the resource type and the resource ID for a production order in Axapta X++

 To  get the resource type and the resource ID  for a production order in Axapta x++ you can get help from below code sample. ProdRoute                       prodRoute;     RecId                           recId;     WrkCtrId                        wrkCtrGrpId;     ProdId                          prodId = "W000170";     WrkCtrActivityRequirementType   WrkCtrActivityRequirementType;     WrkCtrActivityRequirement       wrkCtrActivityRequirement;     while select prodRoute         where prodRoute.ProdId == prodId     {         recId = prodRoute.activityRequirementSet().RecId;   ...

Error while performing workflow approval on EP page in Axapta for Expense report

  Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (0450df4e-1a8a-4e2b-9242-343575bfa1e4).  Reason: An update conflict has occurred, and you must re-try this action. The object SearchDataAccessServiceInstance was updated by FFCM\sysadmin, in the OWSTIMER (15080) process, Tried below steps but not yet resolved issue.. Your valuable feedback comments are welcome. https://learn.microsoft.com/en-us/archive/blogs/jamesway/sharepoint-2010-clearing-the-configuration-cache

Error while opening Enterprise portal Page in Ax 2012

 Getting below error when opening Expense report page for workflow approval. An unhandled error has occurred. To view details about this error, enable debugging in the web.config file or view the Windows event logs. An exception of type MetdataException has occurred while performing the operation. mscorlib Server stack trace:     at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]:     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, I...

How to Split the string value by using separator in Axapta x++

 TextBuffer buffer; str value; Counter cnt; value = "1212-43434-3434-64545"; buffer = new TextBuffer(); buffer.setText(value); while (buffer.nextToken(0, '-')) { cnt++; if(cnt == 1) info (strFmt("first %1",buffer.token())); if(cnt == 2) info (strFmt("two %1",buffer.token())); if(cnt == 3) info (strFmt("three %1",buffer.token())); if(cnt == 4) info (strFmt("four %1",buffer.token())); }

Open form by code in Ax 2012 | open form by Menuitem in Axapta

 Open form by code  FormRun formRun; Args args = new Args(); ; args.name(formstr(CustTable)); args.record(CustTable::find("XYZ")); formRun = ClassFactory.formRunClass(args); formRun.init(); formRun.run(); formRun.wait(); open form by Menuitem Args args = new Args(); ; args.record(CustTable::find("XYZ")); new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run(Args);

How to import model store in Ax 2012

To import model store in Ax 2012 you can use below steps. Thanks. 1.  Execute the AxUtil.exe  executable file command on this path. C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\AXUtil.exe 2.GO command prompt then change to following path. c:\>cd Program Files\Microsoft Dynamics AX\60\ManagementUtilities\ c:\ Program Files\Microsoft Dynamics AX\60\ManagementUtilities\>Axutil importstore /file:"Model file path"

Solution for unbalanced TTSBegin TTSCommit level Error in Axapta

Some time you may faced this error. An unbalanced X++ TTSBEGIN?TTSCOMMIT pair has been detected. The current TTS level is "1"" static void resetTTS(Args _args) {    while (appl.ttsLevel() > 0)    ttsAbort; }

Export data to Excel in D365 F&O using OfficeOpenXml

  using System.IO; using OfficeOpenXml; using OfficeOpenXml.Style; using OfficeOpenXml.Table; class SRWriteToExcel {     public static void main(Args _args)     {         CustTable custTable;         MemoryStream memoryStream = new MemoryStream();         using (var package = new ExcelPackage(memoryStream))         {             var currentRow = 1;             var worksheets = package.get_Workbook().get_Worksheets();             var CustTableWorksheet = worksheets.Add("Export");             var cells = CustTableWorksheet.get_Cells();             OfficeOpenXml.ExcelRange cell = cells.get_Item(currentRow, 1);             System.String value = "Account Number";             cell.se...

X++ Code to read data from Excel Using D365 F&O

 To read data from Excel You can get idea from below sample code. using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; using OfficeOpenXml.ExcelRange; class SRGetDataFromExcel {            public static void main(Args _args)     {          System.IO.Stream            stream;         ExcelSpreadsheetName        sheeet;         FileUploadBuild             fileUpload;         DialogGroup                 dlgUploadGroup;         FileUploadBuild             fileUploadBuild;         FormBuildControl            formBuildControl;         Dialog                ...

get sales order totals in Axapta

 SalesTotals salesTotals;         SalesTable salesTable;         SalesLine salesLine;         TaxAmountCur salesAmt,taxAmount,amt1,discountAmt,totcharges,totOfOrder,contributionRatio;         Tax tax;         ;         salesTable = SalesTable::find("STestSO00002");         salesLine = SalesLine::find(salesTable.SalesId);         salesTotals = SalesTotals::construct(salesTable, SalesUpdate::All);         tax = Tax::construct(NoYes::No);         salesAmt    = salesTotals.totalBalance();         taxAmount   = salesTotals.totalTaxAmount();         discountAmt = salesTotals.totalEndDisc();         totcharges  = salesTotals.totalMarkup();         totOfOrder  = salesTotals.totalAmount...

Unreserve the inventory from sales orders or lines in Axapta

 InventTrans             inventTrans;     InventTransOrigin       inventTransOrigin;     SalesLine               salesLine;     InventMovement          inventMovement;     InventUpd_Reservation   inventUpd_Reservation ;     SalesId                 SalesId = "TesSo0001";//get sales id        // Remove reservations and markings on a reserved salesorder     while select inventTrans         where inventTrans.StatusReceipt                == StatusReceipt::None            && (inventTrans.StatusIssue                 == StatusIssue::ReservPhysical             ||...