New form is not populated with values

There is need to show all parts of one area. I created new form PMCContractAreasDialog. When I click on specific contract line into contract form it should open new form and show all parts of one area. In sum there should be same like on contract line. But every time when I click on button form is empty. Am I missing something ?

[Form]
public class PMCContractAreasDialog extends FormRun
{

    [FormObservable]
    date                                currWorkingDate;

    [FormObservable]
    boolean                             commonAreasRead;

    PMERentalObjectAreaValueCl          tmpRentalAreaCl;
    PMETmpRentalObjectArea              tmpArea;


    public void init ()
    {
        super();

        pmcContractLine_ds.linkActive();

    }

    public void activate(boolean _active)
    {
        PMCContractArea contractArea;
        AmountMST sumContractArea;


        pmcContractLine_ds.readCommonAreas(pmcContractLine);
        h1_h2.realValue(pmcContractLine_ds.h1_h2(pmcContractLine));
        efa.realValue(pmcContractLine_ds.efa(pmcContractLine));
        bfa.realValue(pmcContractLine_ds.bfa(pmcContractLine));
        mfa.realValue(pmcContractLine_ds.mfa(pmcContractLine));
        sumArea.realValue(h1_h2.realValue() + efa.realValue() + bfa.realValue() + mfa.realValue());

    }

    [DataSource]
    class PMCContract
    {
        public int active()
        {
            int ret;

            ret = super();

            return ret;
        }

    }

    [DataSource]
    class PMCContractLine
    {
        public int active()
        {
            int ret;

            ret = super();

            return ret;
        }

        display PMEAreaCommonBuildingSum BFA(PMCContractLine _contractLine)
        {
            if (commonAreasRead)
            {
                if (_contractLine.RentalObjectId)
                {
                    return PMERentalObjectAreaCl::getRentalObjectCommonAreaBuildingSum(_contractLine.RentalObjectId, currWorkingDate, tmpArea, false);
                }
                else
                {
                    return 0;
                }
            }

            return 0;
        }

        void readCommonAreas(PMCContractLine _contractLine)
        {
            if (!commonAreasRead)
            {
                if (pmcContractLine.RentalObjectId)
                {
                    tmpRentalAreaCl = new PMERentalObjectAreaValueCl();

                    tmpRentalAreaCl.clear();
                    tmpRentalAreaCl.getRentalObjectAreas(_contractLine.RentalObjectId, PMGUser::find().currDate());
                    tmpArea.setTmpData(tmpRentalAreaCl.getTempTable());

                    commonAreasRead = true;
                }
            }

        }

        //BP Deviation Documented
        display PMEAreaCommonSectionSum EFA(PMCContractLine _contractLine)
        {
            if (commonAreasRead)
            {
                if (_contractLine.RentalObjectId)
                {
                    return PMERentalObjectAreaCl::getRentalObjectCommonAreaSectionSum(_contractLine.RentalObjectId, currWorkingDate, tmpArea, false);
                }
                else
                {
                    return 0;
                }
            }

            return 0;

        }

        //BP Deviation Documented
        display PMEAreaTotal H1_H2(PMCContractLine _contractLine)
        {
            if (commonAreasRead)
            {
                if (_contractLine.RentalObjectId)
                {
                    return PMERentalObjectAreaCl::getRentalObjectMainAreaSectionSum(_contractLine.RentalObjectId, currWorkingDate, tmpArea, false);
                }
                else
                {
                    return 0;
                }
            }

            return 0;        
        }

        //BP Deviation Documented
        display PMEAreaTotal MFA(PMCContractLine _contractLine)
        {
            if (commonAreasRead)
            {
                if (_contractLine.RentalObjectId)
                {
                    return PMERentalObjectAreaCl::getRentalObjectCommonAreaFixedSum(_contractLine.RentalObjectId, currWorkingDate, tmpArea, false);
                }
                else
                {
                    return 0;
                }
            }

            return 0;
        }

    }

    [DataSource]
    class PMCContractArea
    {
        public void delete()
        {
            super();
            this.updateLines();
        }

        public void write()
        {
            super();
            this.updateLines();

        }

        void updateLines()
        {
            ;
            PMCContractArea::updateLineAreas(pmcContractArea.ContractId, pmcContractArea.RentalObjectId);
        }

    }

}
Parents
No Data
Reply
  • The best approach to understand what's going on in your code is using the debugger.

    If you want to discuss your implementation, it would be good to explain what you're trying to achieve. I don't understand why your form have form datasource that you never bind to controls (at least it's not shown above) and you're trying to populate controls manually from code. You use display methods, but again you don't bind controls to them; you just call them directly. Then no capabilities of display methods will be used and things like FormObservable attributes will have no effect.

    Also, the active() method on form, that should update the controls, isn't called at all.

    And there are other questions... I suggest you start by reviewing your overall architecture. Maybe you should first how to design this behavior, if you're not familiar with D365FO.

Children
Related
Recommended