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 479

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.

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,748 Moderator on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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.

  • Suggested answer
    YUN ZHU Profile Picture
    85,629 Super User 2025 Season 1 on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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

  • jdrco Profile Picture
    479 on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

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

  • Suggested answer
    YUN ZHU Profile Picture
    85,629 Super User 2025 Season 1 on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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

  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,748 Moderator on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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.

  • jdrco Profile Picture
    479 on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,748 Moderator on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

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

  • jdrco Profile Picture
    479 on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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
    13,748 Moderator on at
    RE: Error: The object has been run. Use the function CLEAR(Report).

    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.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans