After commit and isNew()

0
Hi, I need to send a POST query with REST after an object has been successfully created in the app, but I can’t find any “elegant” way to implement that: if I use a “before commit” microflow, it’s too early (the transaction can still fail) if I use a “after-commit” microflow, the “isNew()” function returns false, so it’s not possible to know if this is the “creation” commit, or a simple update if I use a boolean attribute “New” in the entity (default value = true), I need to explicitely set it to false in a after-commit microflow ; this is very ugly, and I would need to do that to every entity in the app ... What would you suggest ? Cheers, F
asked
3 answers
2

If you want to model behavior in an event handler and the first thing you check is if the object is new or not. Then it is NOT an event handler.

Simply put the behavior of the event handler in you process logic and not as event handler. Especially a rest call in an event handler. Something I would never consider. As this is behavior you want to control and trigger other then in an event handler.

 

answered
0

I think it depends if the creation of the object is triggered by a user.

If it is, then you might include the POST in your definition of created successfully. So the object can only be considered as ‘created successfully’ whenever the POST has been done successfully as well. Only commit the object after all required ‘operations’ for your object have been done and all of your validations have been passed. If not, then you can raise your error feedback to the user (which could be a failed POST).

If it doesn't, then I would say in the ACo like Tim van Steenbergen has mentioned in the answer above.

answered
0

Hi François,

I’d expect this to be solved with an After create event handler on the entity. Are you facing any issues with this particular event handler?

Or have I simply misunderstood your question :) ?

Regards,

Radhika Wagle

answered