Wednesday, October 7, 2015

How to make dimension mandatory in ax 2012

I want customer dimension mandatory when creating a new customer

Form> CustTable > Method

public boolean checkcustomer(RecId _ledgerDimID)
{
    DimensionAttribute                  dimAttr;
    DimensionAttributeValue             dimAttrValue;
    DimensionAttributeValueSetItem      dimAttrValueSetItem;
    RefRecId                            defaultDimension;
    boolean                             ret;
    ;

    defaultDimension    =   _ledgerDimID;

    dimAttr             =   DimensionAttribute::findByName('Customer');

    select firstonly RecId, DisplayValue from dimAttrValueSetItem
                where dimAttrValueSetItem.DimensionAttributeValueSet == defaultDimension
            join dimAttrValue
                where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue &&
                dimAttrValue.DimensionAttribute == dimAttr.RecId       &&
                dimAttrValue.IsDeleted == false;

    if (!dimAttrValueSetItem.DisplayValue)
    {
        ret  = checkFailed("Customer dimension must be specified.");

    }
    else
    {
        ret = true;
    }

    return ret;
}

go to form level custtable datasource  validateWrite method 

 if(element.checkcustomer(CustTable.DefaultDimension) )
    {
       ret = true;
    }
    else
    {
        ret = false;
    }

No comments:

Post a Comment

update_recordset with joins

 update_recordset with joins update_recordSet storeTransfer         setting      TransactionId = transfertable.TransferId     join transfert...