Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

set active record

Posted on by

Hey!

I have a record gained from an select Statement.

As my form consists of taps and only one data record can be seen at the time, I want to set exactly this record to be the one.

I tried it with element.args().reocrd(myRecord); 

this did not work

and _DS.setRecord does also not work.

It Always sets me the first record of my data source.

What can I do?

greets

*This post is locked for comments

  • Suggested answer
    loijoc08 Profile Picture
    loijoc08 on at
    RE: set active record

    perfectly. this worked for me!

    THANKS!

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: set active record

    Maybe some additional range or relation is preventing your record from being found.

    I would suggest commenting out all other logic than the finding of the record until you get it working. Just focus on opening this form directly from a menu item in AOT, selecting one record in code and calling the data source findRecord() method. If that works, then start putting your old code back piece by piece and see where it breaks.

  • loijoc08 Profile Picture
    loijoc08 on at
    RE: set active record

    1) yes it is coming to this Code. Just bevore the findRecord call, lgdSSCEvaluation has the Right value.

    2.) I tried this, but it Always takes the first record of the table.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: set active record

    1) Does your code execution really go to the "if(lgdLoadSSCDataForEvaluation.isCloseOK()" section?

    2) You call many methods after the findRecord, I suspect that some of those records does data source research or something and loses the record. What if you move "LGDSSCEvaluation_1_DS.findRecord(lgdSSCEvaluation);" to the very end of the if section (after all the element.close* calls)?

  • loijoc08 Profile Picture
    loijoc08 on at
    RE: set active record

    public void init()

    {

       LGDLoadSSCDataForEvaluation lgdLoadSSCDataForEvaluation = LGDLoadSSCDataForEvaluation::construct();

       int                 yearSelected = 0;

       LGDSSCPeriodType    periodSelected;

       Dialog              dialog;

       DialogField         dialogField;

       str                 supplierId;

       LGDSSCEvaluation    lgdSSCEvaluation;

       super();

       if (lgdLoadSSCDataForEvaluation.prompt())

       {

           lgdLoadSSCDataForEvaluation.run();

       }

       if(lgdLoadSSCDataForEvaluation.isCloseOK())

       {

           select * from lgdSSCEvaluation

           where lgdSSCEvaluation.SupplierId == lgdLoadSSCDataForEvaluation.getSupplierId()

           && lgdSSCEvaluation.Year == lgdLoadSSCDataForEvaluation.getYear()

           && lgdSSCEvaluation.Period == lgdLoadSSCDataForEvaluation.getPeriod();

           //element.args().record(lgdSSCEvaluation);

           LGDSSCEvaluation_1_DS.findRecord(lgdSSCEvaluation);

           if(lgdSSCEvaluation.evaluationComplete == 1)

           {

               element.closePriceTransp();

               element.closeConfirm();

               element.closeQuality();

               element.closeProject();

               element.closeFlexibility();

           }

           else

           {

               if(lgdSSCEvaluation.PriceTranspComplete == 1)

               {

                   element.closePriceTransp();

               }

               if(lgdSSCEvaluation.ConfirmComplete == 1)

               {

                   element.closeConfirm();

               }

               if(lgdSSCEvaluation.QualityComplete == 1)

               {

                   element.closeQuality();

               }

               if(lgdSSCEvaluation.ProjectComplete == 1)

               {

                   element.closeProject();

               }

               if(lgdSSCEvaluation.FlexibilityComplete == 1)

               {

                   element.closeFlexibility();

               }

           }

       }

    }

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: set active record

    Can you share your init method, and the executeQuery method of your data source?

  • loijoc08 Profile Picture
    loijoc08 on at
    RE: set active record

    I call it in the init method of the form.

    after the super(); call

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: set active record

    Where do you call myRecord_ds.findRecord(myRecord)? Maybe some other code changes the focus after that? For example if you call myRecord_ds.research() it will lose focus. MyRecord_ds.research(true) will keep the focus.

  • loijoc08 Profile Picture
    loijoc08 on at
    RE: set active record

    Yes, I tried this.

    I get the record like this:

    select * from myRecord

    where …

    & …;

    And then I set this record. And It is only one record. And from debuging I know that it is the Right record.

    But it is not working.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans