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));
}
}
}
}

}

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 :-)

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));
}

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->...