Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Function Info() vs Infolog.add()

(0) ShareShare
ReportReport
Posted on by 516

Hello guys,

Being beginner in F&O development, may I request some advice. If using Info("textMessage") will instantly show the message in the UI, what is the different if we're using Infolog.add() ? and how exactly using it ?

I'm creating a function which having process flow something like this : Processsing TempTable data -> create Sales Order -> Create Sales Invoice. 

While I'm create this in a transaction block (ttsbegin....ttscommit), currently ata each process I'm using Info() to inform the step, for example when Sales Order created, I inform "Sales Order number 999 has been created", etc. 

Issue is, if there is error along the way, for example posting invoice failed, this transactions will roll-back, which is the way I expected. But in the UI looks weird (and misleading) since there was a message (information) saying Sales Order xxx has been created while in reality it is not because it is rolled back.

May I know how to handle this ? 

I have a catch error handling in the end, since I also put this process under Try..Catch() block, can I use infolog.add() instead, so the info can be hidden first, but if there is an error, I think I want to have an error log saying Sales Order has been created for helping us to identify at least Sales Order process is passed and the error surely after that process. 

Thanks,

  • Ken Manhattan Profile Picture
    Ken Manhattan 516 on at
    RE: Function Info() vs Infolog.add()

    Yes, when there is error, I am execute throw error().

    User will know there is an error at later stage, however the previous message also visible to see, the info(), which user may not know that all preceded process (example : the Sales Order) are not exist because it is rolled back . So I want to know how to handle it correctly to not misleading.

    Thanks.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Function Info() vs Infolog.add()

    But if you have any error, have you tried throw error() ?

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,868 Most Valuable Professional on at
    RE: Function Info() vs Infolog.add()

    info() is a static method defined in Global class. If you open its definition, you'll see what it does - it calls infolog.add(). It's just a shorter way to do the same.

    The other question doesn't match the topic of this thread (Function Info() vs Infolog.add()). I'll answer it, but please create a separate thread next time.

    Messages in infolog aren't a part of a database transaction, therefore a transaction rollback indeed has impact on it. You must remove messages by yourself. You can remember the starting number of messages (infologLine()) and then remove new ones (infolog.clear()).

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... 292,031 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,868 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans