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

Announcements

News and Announcements icon
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).

(2) ShareShare
ReportReport
Posted on by 485

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,306 Super User 2026 Season 1 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
    485 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,306 Super User 2026 Season 1 on at

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

  • jdrco Profile Picture
    485 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,306 Super User 2026 Season 1 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
    102,054 Super User 2026 Season 1 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
    485 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
    102,054 Super User 2026 Season 1 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,306 Super User 2026 Season 1 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.

  • Suggested answer
    Hariom Singh Profile Picture
    7 on at
    Hi, I recently faced this problem also, So I created an alternate solution to achieve what I want. Here I used a Global variable and a public procedure in report/report extension which you can use to end the recurring loop once the process is done. Here it is. Hope this helps
     
    The object has been run. Use the function CLEAR(Report). BC/NAV Issue 

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,687 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,041 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 974 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans