Search code examples
axaptamicrosoft-dynamicsdynamics-ax-2012x++

AX 2012 Auto-fill part of Account structure


i want to know if it is possible to develop following feature. I have a config of this account strucure:

account structure

This is what the journal creation looks for the user: enter image description here

Now i want to develop, if the Lookup return only one opportunity, that the system choose this by default. For the user would mean this, that he choose an agreement and skipped the steps where he choose the BusModel, Vessel, Owner and only has to choose the VAC. Anybody an idea? BG James


Solution

  • OK i develop another feature, that fits for me.

    In the class LedgerDimensionAccountController in the method segmentValueChanged, i develop something like this:

    else if (strLen(newValue) > 0)
        {
            // First assume string is a record value
            dimAttributeValue = LedgerDimensionAccountController::getDimensionAttributeValueServer(dimAttributeId, newValue);
            //Custom Code
            try{
                agrdimAttr = dimensionAttribute::findByName("Agreement");
                if(dimAttributeId == agrdimAttr.RecId){
                    busmodel = subStr(newValue, 12, 2);
                    busModeldimAttr = dimensionAttribute::findByName("BusModel");
                    dimAttributeValue2 = LedgerDimensionAccountController::getDimensionAttributeValueServer(busModeldimAttr.RecId, busmodel);
                    vessel = subStr(newValue,1,4);
                    vesdimAttr = dimensionAttribute::findByName("Vessel");
                    dimAttributeValue3 = LedgerDimensionAccountController::getDimensionAttributeValueServer(vesdimAttr.RecId, vessel);
                    automatic =true;
                }else{
                    automatic =false;
                }
            }
            catch (Exception::Error)
            {
                automatic = false;
                info("Error");
            }
            //CustomCode
    

    and at the end of the method

    this.setValue(segmentIndex, dimAttributeValue, newValue);
            if(automatic){
                segmentIndex++;
                this.setValue(segmentIndex, dimAttributeValue2, busmodel);
                segmentIndex++;
                this.setValue(segmentIndex, dimAttributeValue3, vessel);
            }
    

    IN the first step, the dimensionAttribute from BusinessModel and Vessel will be detected. Then we get the DimensionAttributeValue an set it in the second Code section.

    BG James