web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to Define Financial Dimensions on Purchase Requisition line Grid

(0) ShareShare
ReportReport
Posted on by 2

Hi All,

I have a requirement to be able to insert financial dimensions to the purchase requisition lines through the lines grid instead of going into the details page and inserting through the Financial Dimensions Tab.

At the moment i have added a ledger dimension field on the PurchReqline table and used the LedgerDimensionAccountController to insert a segmented entry on the grid to insert financial dimensions and main account. Now i want to know that if I can add the dimensions selected by the user on the grid (segmented entry) to actual financial dimension tab in the details tab using the DimensionDefaultingController.setDimensionAttributeValue method. I was trying to do so but didn't succeed yet.

Please help me on it and also if there is any other way to fulfill my requirement

*This post is locked for comments

  • ALoureiro Profile Picture
    on at

    Hi there,

    I have a pretty similar requirement.

    Did you succeed with that approach?

    Thanks!

  • Suggested answer
    Denis Patrakov Profile Picture
    on at

    [quote user="dynamics developer"]I have a requirement to be able to insert financial dimensions to the purchase requisition lines through the lines grid instead of going into the details page and inserting through the Financial Dimensions Tab.[/quote]Many people (especially with AX 2009/AX 4.0 experience) have such a wish, but sorry, it doesn't seem to be possible without massive AX customizations.

    [quote user="dynamics developer"]At the moment i have added a ledger dimension field on the PurchReqline table and used the LedgerDimensionAccountController to insert a segmented entry on the grid to insert financial dimensions and main account. Now i want to know that if I can add the dimensions selected by the user on the grid (segmented entry) to actual financial dimension tab in the details tab.[/quote]Those are two different things: DefaultDimension represents just an arbitrary set of dimension attribute values (zero or one value for each attribute); LedgerDimension is a valid dimension attribute value combination. Not all dimension attribute value sets can be valid dimension attribute value combinations depending on your ledger account structures, so it might be not always possible to enter dimension attribute values through a segmented entry control for a desired dimension attribute value set.

    Anyway, you can "parse" your LedgerDimension value "internals" by using DimensionStorage class to get a corresponding DefaultDimension: enumerate segments from 1 to segmentCount(), get dimension attribute id and value for each segment, and then "feed" them to DimensionDefaultingController.setDimensionAttributeValue().

  • Verified answer
    dynamics developer Profile Picture
    2 on at

    Hey ALoureiro,

    I did succeed in adding financial dimensions on Requisition Lines but not using segmented entry. Instead I used string fields and made a lookup for the MainAccount and Department dimensions using the following code

    //For the department
    public void lookup()
    {
            SysTableLookup                  sysTableLookup;
            QueryBuildDataSource            queryBuildDataSource,queryBuildDataSource2;
            QueryBuildRange                 queryBuildRange,queryBuildRange2,queryBuildRange3,queryBuildRange4;
            Query                           query = new Query();
    
            sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit), Dimension_Department);
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber ));
            sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name ));
    
            queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
            queryBuildDataSource.addOrderByField(fieldnum(OMOperatingUnit, OMOperatingUnitNumber));
    
            queryBuildRange=queryBuildDataSource.addRange(fieldNum(OMOperatingUnit,OMOperatingUnitType));
            queryBuildRange.value(enum2Value(OMOperatingUnitType::OMDepartment));
    
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.parmQuery(query);
    
    
    
            if (sysTableLookup)
            {
                sysTableLookup.performFormLookup();
            }
    }

    //For the MainAccount
    public void lookup()
    {
            SysTableLookup                  sysTableLookup;
            QueryBuildDataSource            queryBuildDataSource,queryBuildDataSource2;
            QueryBuildRange                 queryBuildRange,queryBuildRange2,queryBuildRange3,queryBuildRange4;
            Query                           query = new Query();
    
            //super();
            sysTableLookup = SysTableLookup::newParameters(tableNum(MainAccount), Dimension_MainAccount);
            sysTableLookup.addLookupfield(fieldNum(MainAccount, MainAccountId ));
            sysTableLookup.addLookupfield(fieldNum(MainAccount, Name ));
    
            queryBuildDataSource = query.addDataSource(tableNum(MainAccount));
            queryBuildDataSource.addOrderByField(fieldnum(MainAccount, MainAccountId));
    
            queryBuildRange=queryBuildDataSource.addRange(fieldNum(MainAccount,LedgerChartOfAccounts));
            queryBuildRange.value("your ledger recid");
    
            sysTableLookup.parmUseLookupValue(false);
            sysTableLookup.parmQuery(query);
    
    
    
            if (sysTableLookup)
            {
                sysTableLookup.performFormLookup();
            }
    }


     I called the form's updateDefaultDimension method at appropriate places to set the default dimension.

    Hope this helps.

    Thanks

  • Verified answer
    dynamics developer Profile Picture
    2 on at

    Forgot to mention that I used following edit methods for the lookups on  the grid to set the default dimension.

    public edit str 20 editDefaultDimensionDepartment(boolean set, str 20 _department)
    {
        str 20                              department;
        ebiz_DimensionControllerHelper      dimensionController;
    
    
        dimensionController = new ebiz_DimensionControllerHelper();
        if(set)
        {
                this.DefaultDimension   = dimensionController.getNewDefaultDimension(this.DefaultDimension,"Department",_department);
                department             = _department;
        }
        else
        {
                department=dimensionController.getDefaultDimension(this.DefaultDimension,"Department");
        }
    
        return department;
    }
    public edit str 20 editDefaultDimensionMainAccount(boolean set, str 20 _mainAccount)
    {
        str 20                              mainAccount;
        ebiz_DimensionControllerHelper      dimensionController;
    
    
        dimensionController = new ebiz_DimensionControllerHelper();
        if(set)
        {
                this.DefaultDimension   = dimensionController.getNewDefaultDimension(this.DefaultDimension,"MainAccount",_mainAccount);
                mainAccount             = _mainAccount;
        }
        else
        {
                mainAccount=dimensionController.getDefaultDimension(this.DefaultDimension,"MainAccount");
        }
    
        return mainAccount;
    }



  • Verified answer
    dynamics developer Profile Picture
    2 on at

    Helper Class methods :

    class ebiz_DimensionControllerHelper()

    {

    }

    public DimensionValue getDefaultDimension(RecId defaultDimension, Name dimName)
    {
    DefaultDimensionView defDimensionView;
    select defDimensionView
    where defDimensionView.DefaultDimension==defaultDimension
    && defDimensionView.Name==dimName;

    return defDimensionView.DisplayValue;
    }

    public RecId getNewDefaultDimension(RecId defaultDimension, Name dimName, str 255 dimValue)
    {
    DimensionAttributeValueSetStorage dimStorage;
    Counter i;
    DimensionAttribute dimAttributeDepartment;
    DimensionAttributeValue dimAttributeValue;
    dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);
    dimAttributeDepartment = DimensionAttribute::findByName(dimName);
    if(dimValue)
    {
    dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttributeDepartment, dimValue, true, true);
    dimStorage.addItem(dimAttributeValue);
    }
    else
    dimStorage.removeDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
    return dimStorage.save();
    }

    public RecId getNewLedgerDimension(RecId ledgerDimension, Name dimName, str 255 dimValue)
    {
    DimensionStorage dimensionStorage;
    DimensionAttribute dimensionAttribute;
    DimensionAttributeValue newDimensionValue;

    // Find the deparment dimension attribute
    dimensionAttribute = DimensionAttribute::findByName(dimName);

    // Find the new department value we want to put in the new combination.
    newDimensionValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, dimValue, true, true);

    // Load a DimensionStorage instance with the old combination and update the first segment with new value
    dimensionStorage = DimensionStorage::findById(ledgerDimension);
    dimensionStorage.setSegment(1,DimensionStorageSegment::constructFromValue(dimValue, newDimensionValue));
    return dimensionStorage.save();
    }

  • Carlo Severini Profile Picture
    95 on at

    Instead of writing code you can move the Financial Dimension FAST TAB from the Detail to the "Header" form (AOT). Tried with Personalization but the client crashes the second time you use the form.

  • dynamics developer Profile Picture
    2 on at

    But my client had a requirement to have it on the grid so that he can just tab through the fields like any other while data entry. They were very specific about this.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans