Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Data not getting selected in the event handler of table

(0) ShareShare
ReportReport
Posted on by 25

I had a requirement where I have to update a inventdimid whenever creating a new batch/production order in prodbom table . I have wrote the logic in oninserting event handler of prodbom table. I tried to debug a code (attached snapshot)

20230116_5F00_225636.jpg

In the line ProdBom peodbomup =sender as ProdBom, it is not selected a data, value is null. It would be great help if if anyone suggests a solution.

Thanks

  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    RE: Data not getting selected in the event handler of table

    CoC (Chain of Command) is an absolutely crucial topic for extensiblity. It's an easier and more powerful way for writing extensions. You define an extension class and override methods. Such a method has the same name and parameters as the method you're extending (such as insert()). You'll use the next keyword to call the base method, and put code before or after this next call to execute code either before or after the standard logic.

    You can refer to the current object by this.

    You can see all these things in my example above.

    You can also easily refer to class variables or form controls by name, you can access protected members, add methods, add class fields and so on.

    Please read Class extension - Method wrapping and Chain of Command in F&O documentation.

  • Vidhi_234 Profile Picture
    Vidhi_234 25 on at
    RE: Data not getting selected in the event handler of table

    Actually I'm a newbie,  didn't used Coc before.

  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    RE: Data not getting selected in the event handler of table

    Are you saying that you think that my code can't be used for a standard table, because you aren't aware of CoC at all? :-o

    If so, I have some great news for you...

  • Vidhi_234 Profile Picture
    Vidhi_234 25 on at
    RE: Data not getting selected in the event handler of table

    Thanks and noted the point for update(). But I'm working on standard table and form, I need current instance of the table. How can I achieve that. Sender as table is not selecting any Data.

  • Martin Dráb Profile Picture
    Martin Dráb 230,853 Most Valuable Professional on at
    RE: Data not getting selected in the event handler of table

    I don't know what the problem is, but can't you avoid the whole situation by simply using CoC?

    By the way, I see you're trying to update a record that hasn't been inserted yet, which would obviously fail. Just set the value and don't call update(); let the system to insert the record.

    With CoC, the code will look somehow like this:

    void insert()
    {
        this.InventDimId = BOM::find(this.BOMId).InventDimId;
    
    	next insert();
    }

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans