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();
}
}
}
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.
01 November 2015
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();
}
}
25 June 2015
Copy records to multiple companies / Insert records to multiple companies in AX 2009/2012
static void InsertRecordsInCompanies( Args _args )
{
ProjTable projTable,_projTable;
Str com;
DataArea dataArea;
;
com = curext();
while select _projTable
where _projTable.CheckCompany == Noyes::Yes
{
while select dataArea
where dataArea.id != curext()
&& dataArea.id != "dat"
{
changeCompany( dataArea.id )
{
if(dataArea.id != com)
{
projTable = null;
projTable.ProjId = _projTable.ProjId;
info(strfmt("%1,%2 %3",projTable.ProjId,_projTable.dataAreaId,projTable.dataAreaId));
}
}
}
}
}
{
ProjTable projTable,_projTable;
Str com;
DataArea dataArea;
;
com = curext();
while select _projTable
where _projTable.CheckCompany == Noyes::Yes
{
while select dataArea
where dataArea.id != curext()
&& dataArea.id != "dat"
{
changeCompany( dataArea.id )
{
if(dataArea.id != com)
{
projTable = null;
projTable.ProjId = _projTable.ProjId;
info(strfmt("%1,%2 %3",projTable.ProjId,_projTable.dataAreaId,projTable.dataAreaId));
}
}
}
}
}
06 June 2015
AX hang up and deadlock when opening general journal and Invoice journal Can not create number sequence in Ax 2009 and AX 2012
I have faced a issue is that when I am creating General journal or Invoice journal system getting hang up and deadlock.
So I found that Number sequence issue, system is unable create number sequence since that number is already generated and Available in NumberSequence-> List
I was trying to delete unused number sequence list no use, there are 2 table to have a look.
NumberSequenceTable
NumberSequenceList
I have tried to delete in table also no Use. Even cant delte unused number sequence list in DB side.
SOlution:
Step.1 Stop AOS.
Step 2 Take DB back up.
Step 3 Delete the unused NumberSequence from NumberSequencList table in the SQL server DB side.
Step 4 Start AOS.
Happy Daxing :-)
So I found that Number sequence issue, system is unable create number sequence since that number is already generated and Available in NumberSequence-> List
I was trying to delete unused number sequence list no use, there are 2 table to have a look.
NumberSequenceTable
NumberSequenceList
I have tried to delete in table also no Use. Even cant delte unused number sequence list in DB side.
SOlution:
Step.1 Stop AOS.
Step 2 Take DB back up.
Step 3 Delete the unused NumberSequence from NumberSequencList table in the SQL server DB side.
Step 4 Start AOS.
Happy Daxing :-)
03 June 2015
DefaultDimension and default financial dimension values through X++ code in AX 2012
Using the dimension values getting default dimension recid:
Example 1.
static void dimension(Args _args)
{
DefaultDimensionView defaultDimensionView,defaultDimensionView1;
VendInvoiceTrans vendInvoiceTrans;
while select defaultDimensionView join vendInvoiceTrans
where vendInvoiceTrans.DefaultDimension == defaultDimensionView.DefaultDimension
&& defaultDimensionView.name == "CostCode"
&& defaultDimensionView.DisplayValue == "DX001"
join defaultDimensionView1
where defaultDimensionView1.DefaultDimension == vendInvoiceTrans.DefaultDimension
&& defaultDimensionView1.Name == "Project"
&& defaultDimensionView1.DisplayValue == "TIPL-000044"
{
info(strfmt("%1 %2 ",defaultDimensionView.DisplayValue,vendInvoiceTrans.InvoiceId));
}
}
=============
Using Defult dimension getting Dimension values: Example 1:
ProjTable ProjTable;
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;
while select * from ProjTable
where ProjTable.ProjId == "70001" // To get 70001 dimension values
join RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == ProjTable.DefaultDimension
join RecId, DisplayValue from DimensionAttributeValueSetItem
where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId, Name from DimensionAttribute
where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
{
info(DimensionAttribute.Name+"----"+ DimensionAttributeValueSetItem.DisplayValue);
}
===============
DimensionAttributeValueSetStorage dimStorage;
ProjTable ProjTable;
Counter i;
ProjTable = ProjTable::find("70001"); // To get 70001 dimension values
dimStorage = DimensionAttributeValueSetStorage::find(ProjTable.DefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++) { info(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i)); } ============= ProjTable ProjTable; Counter i; container conDim; ProjTable = ProjTable::find("70001"); // To get the dimension values for 70001 conDim = AxdDimensionUtil::getDimensionAttributeValueSetValue(ProjTable.DefaultDimension);
for (i=1 ; i<= conLen(conDim) ; i++)
{
info(conPeek(conDim,i));
}
Example 1.
static void dimension(Args _args)
{
DefaultDimensionView defaultDimensionView,defaultDimensionView1;
VendInvoiceTrans vendInvoiceTrans;
while select defaultDimensionView join vendInvoiceTrans
where vendInvoiceTrans.DefaultDimension == defaultDimensionView.DefaultDimension
&& defaultDimensionView.name == "CostCode"
&& defaultDimensionView.DisplayValue == "DX001"
join defaultDimensionView1
where defaultDimensionView1.DefaultDimension == vendInvoiceTrans.DefaultDimension
&& defaultDimensionView1.Name == "Project"
&& defaultDimensionView1.DisplayValue == "TIPL-000044"
{
info(strfmt("%1 %2 ",defaultDimensionView.DisplayValue,vendInvoiceTrans.InvoiceId));
}
}
=============
Using Defult dimension getting Dimension values: Example 1:
ProjTable ProjTable;
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;
while select * from ProjTable
where ProjTable.ProjId == "70001" // To get 70001 dimension values
join RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == ProjTable.DefaultDimension
join RecId, DisplayValue from DimensionAttributeValueSetItem
where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId, Name from DimensionAttribute
where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
{
info(DimensionAttribute.Name+"----"+ DimensionAttributeValueSetItem.DisplayValue);
}
===============
DimensionAttributeValueSetStorage dimStorage;
ProjTable ProjTable;
Counter i;
ProjTable = ProjTable::find("70001"); // To get 70001 dimension values
dimStorage = DimensionAttributeValueSetStorage::find(ProjTable.DefaultDimension);
for (i=1 ; i<= dimStorage.elements() ; i++) { info(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i)); } ============= ProjTable ProjTable; Counter i; container conDim; ProjTable = ProjTable::find("70001"); // To get the dimension values for 70001 conDim = AxdDimensionUtil::getDimensionAttributeValueSetValue(ProjTable.DefaultDimension);
for (i=1 ; i<= conLen(conDim) ; i++)
{
info(conPeek(conDim,i));
}
29 May 2015
Open a file using X++ code in windows like xml or Excel
static void WindosFile_Open(Args _args)
{
;
WinAPI::shellExecute("D:\\Bank statement1.xlsx");
}
{
;
WinAPI::shellExecute("D:\\Bank statement1.xlsx");
}
05 May 2015
AX 2012 Command prompt compilation / AxBuild.exe for Parallel Compile on AOS of X++ to p-code
Go to cmd prompt
C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin>
axbuild.exe xppcompileall /s=01
/altbin="C:\Program Files (x86)\Microsoft Dynamics AX\6.0\Client\Bin"
Please click here for more details
C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin>
axbuild.exe xppcompileall /s=01
/altbin="C:\Program Files (x86)\Microsoft Dynamics AX\6.0\Client\Bin"
Please click here for more details
22 April 2015
RecId number sequence maintenance table in AX
SystemSequences is the table maintaing the every table next RecId sequence value.
06 April 2015
How to copy The One company DATA another company
static void copyDataToOthercompanies(Args _args)
{
DataArea dataArea;
ExchRates ex;
Currency cr;
str currentyCom;
currentyCom = curext();
while select dataArea where ! dataArea.isVirtual
{
changecompany (dataArea.Id)
{
ttsbegin;
if(dataArea.id != currentyCom)
//select forupdate cr;
{
cr = null;
//cr.data(dataArea);
cr.CurrencyCode = "XPT";
cr.Txt = "XPPPPPT";
cr.CurrencyCodeISO = "XPT";
cr.insert();
}
ttscommit;
}
}
}
{
DataArea dataArea;
ExchRates ex;
Currency cr;
str currentyCom;
currentyCom = curext();
while select dataArea where ! dataArea.isVirtual
{
changecompany (dataArea.Id)
{
ttsbegin;
if(dataArea.id != currentyCom)
//select forupdate cr;
{
cr = null;
//cr.data(dataArea);
cr.CurrencyCode = "XPT";
cr.Txt = "XPPPPPT";
cr.CurrencyCodeISO = "XPT";
cr.insert();
}
ttscommit;
}
}
}
16 February 2015
Claims to Windows Token Service in SharePoint Central Administration - AX 2012 R3 EP installation warning / error
22 January 2015
Test Services in AX 2012
Visual Studio Command Prompt by going to All Programs à Microsoft Visual Studio 2010 à Visual Studio Tools à Visual Studio Command Prompt.
Write wcftestclient and press enter. WCF Test Client will open.
Please click here for more information
Write wcftestclient and press enter. WCF Test Client will open.
Please click here for more information
21 January 2015
Default dimension in AX 2012 for customer or vendor X++ code
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
// Note that "Item" is not one of the default dimension,
// but DimensionAttributeValueSetStorage will handle it gracefully
container conAttr = ["BusinessUnit","CostCenter","Department", "ItemGroup", "Project"];
container conValue = ["004", "009", "024","Services","000007"];
str dimValue;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
// The last parameter is "true". A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
DimensionDefault result;
int i;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
// Note that "Item" is not one of the default dimension,
// but DimensionAttributeValueSetStorage will handle it gracefully
container conAttr = ["BusinessUnit","CostCenter","Department", "ItemGroup", "Project"];
container conValue = ["004", "009", "024","Services","000007"];
str dimValue;
for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
{
continue;
}
dimValue = conPeek(conValue,i);
if (dimValue != "")
{
// The last parameter is "true". A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
}
result = valueSetStorage.save();
14 January 2015
The CIL generator found errors and could not save the new assembly. Error + AX 2012 R3 CU8 Installation error
Hi Guys,
Please check the log in the below link:
\Program Files\Microsoft Dynamics AX\60\Server\YOUR_INSTANCE\bin\XppIL\Dynamics.Ax.Application.dll.log
Thanks
Happy daxing
Please check the log in the below link:
\Program Files\Microsoft Dynamics AX\60\Server\YOUR_INSTANCE\bin\XppIL\Dynamics.Ax.Application.dll.log
Thanks
Happy daxing
Subscribe to:
Posts (Atom)
Ledger Voucher creation Framework and x++ code to create ledger voucher
Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...
-
{ "Message" : "Please verify that the user is valid and set up correctly." } Sol: System Administration > Se...
-
Please click here to access Custom Workflow step by step process:
-
FormRun formRun = sender.formRun(); Object inventTrans_ds = formRun.dataSource(formDataSourceStr(InventMarking,InventTransO...