web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Error: The object has been run. Use the function CLEAR(Report).

(0) ShareShare
ReportReport
Posted on by 481

The object has been run. Use the function CLEAR(Report).

Where am I supposed to call that clear function?

pastedimage1657047361558v1.png

I am trying to email a report as a pdf as soon as it is run.

I have the same question (0)
  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 on at

    I don't think you can put the SaveAs logic inside the report.

    When you use SaveAs, BC will run the report once and save the result in PDF.

    If you put the SaveAs logic inside the report, it will basically go into loop.

    Put the whole email logic inside codeunit and run it.

  • jdrco Profile Picture
    481 on at

    TeddyH Where would I call the codeunit? Is there an event for when the report is run outside of the report extension object? I am facing recursion issues if I call the codeunit in the same report still

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 on at

    Where do you call the report ? Do you call it from a page ? If yes, put it there.

  • jdrco Profile Picture
    481 on at

    TeddyH  I just want to automatically email a report to a customer after they run the report. That is why I wanted to call it in the report object itself. Is this even possible?

    pastedimage1657051764939v1.pngImage

  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 on at

    There is no way you can do that from inside the report.

    What you should do is create an action on the page. When user click the page, fill in the parameter for the report, run saveas and send the email.

    You cannot preview/print the report and send itself at the same time.

  • Suggested answer
    YUN ZHU Profile Picture
    95,681 Super User 2025 Season 2 on at

    Hi, Teddy is right, I have tested this before and got the same error as you.

    pastedimage1657077625039v1.png

    pastedimage1657077634849v2.png

    So I think you should change your solution, for example, you can do this on the OnAction trigger (after or before) of the page button.

    Hope this can give you some inspiration.

    Thanks.

    ZHU

  • jdrco Profile Picture
    481 on at

    Is there a way to have that OnAction trigger on a button from the report's request page?

  • Suggested answer
    YUN ZHU Profile Picture
    95,681 Super User 2025 Season 2 on at

    As far as I know, there is no way. Because general actions cannot be added to the request page.

    More details: https://yzhums.com/21114/

    You can only do what Teddy said, create an action to the normal page.

    Hope this help as well.

    Thanks.

    ZHU

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 on at

    If you insist of sending pdf everytime user run the report, what you can do is to create a new table and insert the record to that table everytime user print the report.

    A job queue will run regularly to check that table and send a pdf accordingly.

    Or you can go back and ask the question whether it is necessary to do it that way.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans