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,
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.
But if you have any error, have you tried throw error() ?
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()).
André Arnaud de Cal...
292,031
Super User 2025 Season 1
Martin Dráb
230,868
Most Valuable Professional
nmaenpaa
101,156