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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Function Info() vs Infolog.add()

(0) ShareShare
ReportReport
Posted on by 558

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,

  • Suggested answer
    Martin Dráb Profile Picture
    241,441 Most Valuable Professional on at

    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()).

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

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

  • Ken Manhattan Profile Picture
    558 on at

    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.

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 363 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 188

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans