31 October 2016

Print management does not show the new report design in AX 2012

We have to add the code to populate the new design : PrintMgmtReportFormat.populate()
Ex:
public server static void populate()
{
.
.
.
.
.

addOther(PrintMgmtDocumentType::Quotation,'SalesQuotation.Report_FR','SalesQuotation.Report_New',#NoCountryRegionId);
ttscommit;
.
.
.
}

27 October 2016

How to get Site contact details / Electronic address / Phone Email in AX 2012

Please refer the below image that will help to under relation between related tables.

static void inventSiteElectronicAddress(Args _args)
{
InventSite inventSite;
InventSiteLogisticsLocation inventSiteLogisticsLocation;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress logisticsElectronicAddress;

inventSite = InventSite::find("ARNAGE"); // ARNAGE is the inventsite name

select firstonly inventSiteLogisticsLocation
where inventSiteLogisticsLocation.Site == inventSite.RecId
join firstonly logisticsLocation
where logisticsLocation.ParentLocation == inventSiteLogisticsLocation.Location
join firstOnly logisticsElectronicAddress
where logisticsElectronicAddress.Location == logisticsLocation.RecId
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone
&& logisticsElectronicAddress.IsPrimary == NoYes::Yes;

info(logisticsElectronicAddress.Locator);
}

25 October 2016

how to get Dimension Value using Default dimension in AX 2012

Option 1:

DimensionAttributeValueSetStorage    dimStorage;
str dimval;

dimval = DimensionAttributeValueSetStorage::find(salesQuotationTable.DefaultDimension).getDisplayValueByIndex(2);
info(strFmt("%1",dimval));

Option 2:

public void financialDimValue(Name _attributeName)
{
    DimensionAttributeValueSet          ceDimensionAttributeValueSet;
    DimensionAttributeValueSetItem      ceDimensionAttributeValueSetItem;
    DimensionAttributeValue             ceDimensionAttributeValue;
    DimensionAttribute                  ceDimensionAttribute;
    ;

    select RecId from ceDimensionAttributeValueSet
        where  ceDimensionAttributeValueSet.RecId == salesQuotationTable.DefaultDimension
    join RecId, DisplayValue from ceDimensionAttributeValueSetItem
        where ceDimensionAttributeValueSetItem.DimensionAttributeValueSet == ceDimensionAttributeValueSet.RecId
    join RecId from ceDimensionAttributeValue
        where ceDimensionAttributeValue.RecId == ceDimensionAttributeValueSetItem.DimensionAttributeValue
    join RecId, Name from ceDimensionAttribute
        where ceDimensionAttribute.RecId == ceDimensionAttributeValue.DimensionAttribute
        && ceDimensionAttribute.Name == _attributeName;

    inventSite          =   InventSite::find(ceDimensionAttributeValueSetItem.DisplayValue);
}

13 October 2016

AX 7 & AX 2012 How to get default address for the same type of address Like Delivery

When there are Delivery type address are multiple to get default address:
Below is the class to use to get Default address.

Class: LogisticsLocationDefault

Reference: code:

\Data Dictionary\Tables\SalesTable\Methods\initFromCustTableMandatoryFields

location = LogisticsLocationDefault::findSimpleDefault(custTable, LogisticsLocationRole::findBytype(
LogisticsLocationRoleType::Delivery));

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