Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Call an Update Report from OnInsert trigger

Posted on by 2

Hi,

I am trying to automate a Production Refresh when a Production Line is created.

However, when I add the report.run in the OnInsert, I get an error that the transaction type can't be chagned from UpdateLocks to Update.

Is there a way I could call the update report Asynchronously so that it does it after the insert transaction is completed?

*This post is locked for comments

  • SamCha Profile Picture
    SamCha 2 on at
    RE: Call an Update Report from OnInsert trigger

    Ok, one step further now.

    By setting CalcLines it doesn't error out, but the line at that point is not created yet (since I'm still in the OnInsert trigger).

    So the component calculation works only for the first line when I insert a second line, so I always have hte last one that is not calculated.

    I guess I'll need another place to use call that code. Is there an afterinsert on the Page?

  • SamCha Profile Picture
    SamCha 2 on at
    RE: Call an Update Report from OnInsert trigger

    Yes I want it to calculate components automatiacally when we add a line.

    Otherwise, people forget to do it and post an empty production...

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Call an Update Report from OnInsert trigger

    Why you want to run the refresh production order on line insert ? are you planning to calculate components/routings ? if you are planning to calculate lines then it will not make any sense to do that during insert of a line. If you want to calculate components then on the report make sure you uncheck the lines to calculate.

  • SamCha Profile Picture
    SamCha 2 on at
    RE: Call an Update Report from OnInsert trigger

    I tried adding a "Commit" before my call to the update report, but it didn't help.

    Any other ideas?

  • SamCha Profile Picture
    SamCha 2 on at
    RE: Call an Update Report from OnInsert trigger

    It works, but I get this error. Not sure why it tries to add it a second time.

    "Prod. Order Line already exists"

    I tried from the Table Line OnInsert and also from the Page OnInsert, and it does the same error.

  • SamCha Profile Picture
    SamCha 2 on at
    RE: Call an Update Report from OnInsert trigger

    Edit: Nevermind this message.

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Call an Update Report from OnInsert trigger

    Create a copy of the refresh production order report and change the Transaction Type to UpdateLocks and use that in the Oninsert.

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