This blog is for Dynamics AX (AXAPTA) Developers,this will help you for your development issues. This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
05 January 2016
01 November 2015
How to get the AX info infolog value in ax 2009 / 2012 Exception handling example.
static void exceptionHandling(Args _args)
{
CustTable cust;
int i;
CustProjErrorStack custProjErrorStack;
;
try{
while select cust where cust.ABC_Approval != noyes::Yes
{
if(CustTable::find(cust.AccountNum))
{
}
}
}
catch(exception::Error)
{
for (i=1; i<=infolog.line(); i++)
{
custProjErrorStack.ErrorType = ErrorType::Error;
custProjErrorStack.Message = infolog.text(i);
custProjErrorStack.insert();
}
}
}
{
CustTable cust;
int i;
CustProjErrorStack custProjErrorStack;
;
try{
while select cust where cust.ABC_Approval != noyes::Yes
{
if(CustTable::find(cust.AccountNum))
{
}
}
}
catch(exception::Error)
{
for (i=1; i<=infolog.line(); i++)
{
custProjErrorStack.ErrorType = ErrorType::Error;
custProjErrorStack.Message = infolog.text(i);
custProjErrorStack.insert();
}
}
}
28 September 2015
Woflow AX 2009 and AX 2012
Purchase order workflow -> enable and disable the posting buttons.
\Classes\PurchTableType\mayInvoiceBeUpdated
//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;
if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end
\Classes\PurchTableType\mayPurchaseOrderBeUpdated
//For PO workflow begin
select firstonly workflowConfigurationTable
where workflowConfigurationTable.TemplateName == "PurchOrderApproval"
&& workflowConfigurationTable.Enabled == Noyes::Yes;
if(workflowConfigurationTable.RecId)
{
ok = ok && (purchTable.State == PurchReqWorkflowState::WorkflowCompleted);
}
//For PO workflow end
11 August 2015
06 August 2015
check the caller from in ax 2012
Public Static void main(Args _args)
{
if(_args.dataset() == tableNum(CustTable))
{
}
}
{
if(_args.dataset() == tableNum(CustTable))
{
}
}
04 August 2015
How to pass the parameter when opening the MenuItem using X++ code AX 2009 / AX 2012
static void OpenDisplayMenuItem()
{
Args args = new Args();
;
args.record(VendTable::find("XYZ"));
new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
}
{
Args args = new Args();
;
args.record(VendTable::find("XYZ"));
new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);
}
09 July 2015
Read XML file in AX 2009 / 2012
static void ReadXml_New(Args _args)
{
XmlDocument xmlDoc;
#define.node("Data\Invoice")
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord;
XmlNodeList xmlRecordList;
XmlNodeList xmlFieldList;
XMLElement xmlEl;
XMLNode xmlNode;
//CustTable carTable;
//DictTable dTable = new DictTable(tablenum(CarTable));
int i, j, fieldId;
//#CarsXmlTags
;
// Create an XmlDocument object to hold the
// contents of the xml-file
xmlDoc = new XmlDocument();
// Load the content of the xml-file
// into the XmlDocument object
xmlDoc.load(@"c:\Users\abc\Desktop\myxmlInvoice.xml"); // @'C:\Users\abc\Desktop\Invoice.xml'
// permission.assert();
//doc = XMLDocument::newXml(xmlDoc); // this line is to take xml parse data as a parameter and creating new xml file in the code.
// Get the root node
xmlRoot = xmlDoc.getNamedElement("Data");
// Get all child nodes (records)
xmlRecordList = xmlRoot.childNodes();
// Loop through the list of records
for (i=0; i
//carTable.clear();
// Get the current record from the
// record list
xmlNode = xmlRecordList.nextNode();
xmlRecord = xmlRecordList.item(i);
// Get all child nodes (fields)
xmlFieldList = xmlRecord.childNodes();
// Loop through the list of fields
for (j=0; j
// Get the current field from the
// field list
xmlField = xmlFieldList.item(j);
// Set the matching field in the carTable
// to be equal to the inner text
// (the text between the tag and end tag).
info(xmlField.name());
//carTable.(dTable.fieldName2Id(xmlField.name())) =
info(xmlField.innerText());
}
// Insert the record into the carTable
//carTable.insert();
}
}
Subscribe to:
Posts (Atom)
Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O
[DataContractAttribute] class ABCUserProfilesBulkDeleteContract { UserId userId; [DataMemberAttribute('UserId')] pu...
-
Please click here to access Custom Workflow step by step process:
-
public InventQty onHandInventory(ItemId itemId, InventSiteId inventSiteId,InventLocationId inventLocation) { InventOnhand inventOnh...
-
1. In classDeclaration extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase 2. Temp table properties should b...
