Re: [idempiere] PO_AFTER_NEW Event Handler not running after new record saved in db

75 views
Skip to first unread message
Message has been deleted

Heng Sin Low

unread,
May 25, 2023, 11:10:12 PM5/25/23
to idem...@googlegroups.com
replace MUser user = MUser.get with MUser user = (MUser)po;

To avoid the need of cast above, you can use https://wiki.idempiere.org/en/NF9_OSGi_New_Event_Handling_Annotation instead.

On Fri, May 26, 2023 at 10:47 AM Ari Prayoga Hutabarat <aripra...@gmail.com> wrote:
Dear All  🙏

Hope you all well & healthy 🙏

I'm using Idempiere 10. Currently i want to make when admin create new user. The New user will 
automatically assign to default role.
In this case i'm using AbstractEventHandler with event topic PO_AFTER_NEW. in doHandleEvent 
i have get the new UserId to add in UserRole table. But when i create new object of MUserRole
and saveEx. There is eror say that the userID not found in table AD_User, When im try to figure out. 
It's because my code run before PO_AFTER_NEW event complete. Here my code.

Is there some method to check if the event complete and run my code in that method ? Or is there
any way to solve this problem ? Thank you

carbon (2).png

Screenshot_131.png
Screenshot_132.png

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/2f985872-cde6-4146-b0db-52b2c87703ebn%40googlegroups.com.
Message has been deleted

Heng Sin Low

unread,
May 26, 2023, 12:49:50 AM5/26/23
to idem...@googlegroups.com
It should be new MUserRole(..., user.get_TrxName()).
Also, use saveEx(), don't use save().

On Fri, May 26, 2023 at 12:37 PM Ari <aripra...@gmail.com> wrote:
Hi Thank you for your answer. I have using cast above but still get eror userId not present yet in my table.
Screenshot_133.png

Ari

unread,
May 26, 2023, 2:25:21 AM5/26/23
to iDempiere
Thanks Hengsin , it works for me. 
Reply all
Reply to author
Forward
0 new messages