Get values from entity not commited.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Get values from entity not commited.

iwolf
Hi everybody,

I have a question regarding services :

I hava a "eecas" that a service after a new OrderPaymentPreference has been created/stored.

Within this service I would need some fields from OrderHeader entity. Unfortunately at this this point the entity entry is not commited and therefore I cannot query it. Is there a way to get those values. The service "storeOrder" is the service that initiates everything.

I would appreciate every hint.

Thanks,
Ingo
Reply | Threaded
Open this post in threaded view
|

Re: Get values from entity not commited.

Suraj Khurana-2
Hello Ingo,

While defining eca, please use event as 'commit' instead of 'return'. BTW,
I would recommend to use seca over 'storeOrder' if scope is limited to this
service only.

HTH
--
Best Regards,
Suraj Khurana
Technical Consultant
HotWax Systems







On Wed, Jul 3, 2019 at 3:24 PM Ingo Wolfmayr <[hidden email]>
wrote:

> Hi everybody,
>
> I have a question regarding services :
>
> I hava a "eecas" that a service after a new OrderPaymentPreference has
> been created/stored.
>
> Within this service I would need some fields from OrderHeader entity.
> Unfortunately at this this point the entity entry is not commited and
> therefore I cannot query it. Is there a way to get those values. The
> service "storeOrder" is the service that initiates everything.
>
> I would appreciate every hint.
>
> Thanks,
> Ingo
>
Reply | Threaded
Open this post in threaded view
|

Fwd: Get values from entity not commited.

Blurbiness multimedia
In reply to this post by iwolf
Dear Ingo,

The "storeOrder" service is implemented in
org.apache.ofbiz.order.order.OrderServices.java#createOrder. Many related
entities may be created as part of the execution of this service.
Perhaps you may rethink your strategy, depending on your specific needs:

(A) Instead of implementing an EECA for OrderPaymentPreference, try to
implement a service ECA for "storeOrder" service. Pay atenttion to the
"event" attribute in the eca tag, depending on your needs, you may need to
use one of the less common events.

(B) Remember that you could override an OOTB service definition in your own
custom module. Then, you could call the OOTB service method and after the
call, to add additional logic.

Hope this might help.

Regards,

Francisco

*Blurbiness multimedia*

*www.blurbiness.com* <http://www.blurbiness.com>



El mié., 3 jul. 2019 a las 12:31, Ingo Wolfmayr (<[hidden email]>)
escribió:

> Dear Francisco,
>
>
>
> the problem is, that I need to trigger the service on
> "OrderPaymentPreference". I already use the "value-attr" to get the
> OrderPaymentPreference entity. But I need the OrderHeader.
>
>
>
> Thanks,
>
> Ingo
>
>
>
>
>
> *Von:* Blurbiness multimedia <[hidden email]>
> *Gesendet:* Mittwoch, 3. Juli 2019 12:24
> *An:* Ingo Wolfmayr <[hidden email]>
> *Betreff:* Re: Get values from entity not commited.
>
>
>
> Dear Ingo,
>
>
>
> When you define an Entity ECA (EECA), you can add the value-attr attribute
> in the action tag. Then, you will receive a IN parameter in your service
> with the new values for the entity. For example:
>
>
>
> ```
>
> <eca entity="MyEntity" operation="create" event="run">
>       <action service="myServuce" mode="sync" value-attr="newValue"
> abort-on-error="true" rollback-on-error="true"/>
> </eca>
>
> ```
>
>
>
> This way, "myService" will receive an IN parameter called "newValue" which
> will be a GenericValue with the new field values for MyEntity entity
> instance.
>
>
>
> Regards,
>
>
>
> Francisco
>
>
>
> *Blurbiness multimedia*
>
> *www.blurbiness.com* <http://www.blurbiness.com>
>
>
>
> El mié., 3 jul. 2019 a las 11:54, Ingo Wolfmayr (<[hidden email]>)
> escribió:
>
> Hi everybody,
>
> I have a question regarding services :
>
> I hava a "eecas" that a service after a new OrderPaymentPreference has
> been created/stored.
>
> Within this service I would need some fields from OrderHeader entity.
> Unfortunately at this this point the entity entry is not commited and
> therefore I cannot query it. Is there a way to get those values. The
> service "storeOrder" is the service that initiates everything.
>
> I would appreciate every hint.
>
> Thanks,
> Ingo
>
>
>
> --
>
>
>


--



--
Atentamente,

El equipo de Blurbiness



*Blurbiness*
Producción multimedia para su negocio
*www.blurbiness.com* <http://www.blurbiness.com>

[hidden email]
Tel. +(34) 984 49 13 52

C/ San Guillermo, 8, bajo
33210 Gijón (Asturias)
España
Reply | Threaded
Open this post in threaded view
|

AW: Get values from entity not commited.

iwolf
Thank Fancisco & Suraj Khurana,

I changed it to your recommondation.

Best regards,
ingo

-----Ursprüngliche Nachricht-----
Von: Blurbiness multimedia <[hidden email]>
Gesendet: Mittwoch, 3. Juli 2019 13:04
An: [hidden email]
Betreff: Fwd: Get values from entity not commited.

Dear Ingo,

The "storeOrder" service is implemented in org.apache.ofbiz.order.order.OrderServices.java#createOrder. Many related entities may be created as part of the execution of this service.
Perhaps you may rethink your strategy, depending on your specific needs:

(A) Instead of implementing an EECA for OrderPaymentPreference, try to implement a service ECA for "storeOrder" service. Pay atenttion to the "event" attribute in the eca tag, depending on your needs, you may need to use one of the less common events.

(B) Remember that you could override an OOTB service definition in your own custom module. Then, you could call the OOTB service method and after the call, to add additional logic.

Hope this might help.

Regards,

Francisco

*Blurbiness multimedia*

*www.blurbiness.com* <http://www.blurbiness.com>



El mié., 3 jul. 2019 a las 12:31, Ingo Wolfmayr (<[hidden email]>)
escribió:

> Dear Francisco,
>
>
>
> the problem is, that I need to trigger the service on
> "OrderPaymentPreference". I already use the "value-attr" to get the
> OrderPaymentPreference entity. But I need the OrderHeader.
>
>
>
> Thanks,
>
> Ingo
>
>
>
>
>
> *Von:* Blurbiness multimedia <[hidden email]>
> *Gesendet:* Mittwoch, 3. Juli 2019 12:24
> *An:* Ingo Wolfmayr <[hidden email]>
> *Betreff:* Re: Get values from entity not commited.
>
>
>
> Dear Ingo,
>
>
>
> When you define an Entity ECA (EECA), you can add the value-attr
> attribute in the action tag. Then, you will receive a IN parameter in
> your service with the new values for the entity. For example:
>
>
>
> ```
>
> <eca entity="MyEntity" operation="create" event="run">
>       <action service="myServuce" mode="sync" value-attr="newValue"
> abort-on-error="true" rollback-on-error="true"/> </eca>
>
> ```
>
>
>
> This way, "myService" will receive an IN parameter called "newValue"
> which will be a GenericValue with the new field values for MyEntity
> entity instance.
>
>
>
> Regards,
>
>
>
> Francisco
>
>
>
> *Blurbiness multimedia*
>
> *www.blurbiness.com* <http://www.blurbiness.com>
>
>
>
> El mié., 3 jul. 2019 a las 11:54, Ingo Wolfmayr
> (<[hidden email]>)
> escribió:
>
> Hi everybody,
>
> I have a question regarding services :
>
> I hava a "eecas" that a service after a new OrderPaymentPreference has
> been created/stored.
>
> Within this service I would need some fields from OrderHeader entity.
> Unfortunately at this this point the entity entry is not commited and
> therefore I cannot query it. Is there a way to get those values. The
> service "storeOrder" is the service that initiates everything.
>
> I would appreciate every hint.
>
> Thanks,
> Ingo
>
>
>
> --
>
>
>


--



--
Atentamente,

El equipo de Blurbiness



*Blurbiness*
Producción multimedia para su negocio
*www.blurbiness.com* <http://www.blurbiness.com>

[hidden email]
Tel. +(34) 984 49 13 52

C/ San Guillermo, 8, bajo
33210 Gijón (Asturias)
España
Reply | Threaded
Open this post in threaded view
|

AW: Get values from entity not commited.

iwolf
Ok, my last comment was wrong. Using "storeOrder" as initial service does not work as there is an ECA for OrderPaymentPreference. The result is, that the OrderPaymentPreference is not available. I did solve it now as there was a mistake on my side: I had "require-new-transaction=true" set for the service. Turning it to "false" gave me access to everything I need within the transaction.

Thanks for your help.
Best regards
Ingo

-----Ursprüngliche Nachricht-----
Von: Ingo Wolfmayr <[hidden email]>
Gesendet: Mittwoch, 3. Juli 2019 13:37
An: [hidden email]
Betreff: AW: Get values from entity not commited.

Thank Fancisco & Suraj Khurana,

I changed it to your recommondation.

Best regards,
ingo

-----Ursprüngliche Nachricht-----
Von: Blurbiness multimedia <[hidden email]>
Gesendet: Mittwoch, 3. Juli 2019 13:04
An: [hidden email]
Betreff: Fwd: Get values from entity not commited.

Dear Ingo,

The "storeOrder" service is implemented in org.apache.ofbiz.order.order.OrderServices.java#createOrder. Many related entities may be created as part of the execution of this service.
Perhaps you may rethink your strategy, depending on your specific needs:

(A) Instead of implementing an EECA for OrderPaymentPreference, try to implement a service ECA for "storeOrder" service. Pay atenttion to the "event" attribute in the eca tag, depending on your needs, you may need to use one of the less common events.

(B) Remember that you could override an OOTB service definition in your own custom module. Then, you could call the OOTB service method and after the call, to add additional logic.

Hope this might help.

Regards,

Francisco

*Blurbiness multimedia*

*www.blurbiness.com* <http://www.blurbiness.com>



El mié., 3 jul. 2019 a las 12:31, Ingo Wolfmayr (<[hidden email]>)
escribió:

> Dear Francisco,
>
>
>
> the problem is, that I need to trigger the service on
> "OrderPaymentPreference". I already use the "value-attr" to get the
> OrderPaymentPreference entity. But I need the OrderHeader.
>
>
>
> Thanks,
>
> Ingo
>
>
>
>
>
> *Von:* Blurbiness multimedia <[hidden email]>
> *Gesendet:* Mittwoch, 3. Juli 2019 12:24
> *An:* Ingo Wolfmayr <[hidden email]>
> *Betreff:* Re: Get values from entity not commited.
>
>
>
> Dear Ingo,
>
>
>
> When you define an Entity ECA (EECA), you can add the value-attr
> attribute in the action tag. Then, you will receive a IN parameter in
> your service with the new values for the entity. For example:
>
>
>
> ```
>
> <eca entity="MyEntity" operation="create" event="run">
>       <action service="myServuce" mode="sync" value-attr="newValue"
> abort-on-error="true" rollback-on-error="true"/> </eca>
>
> ```
>
>
>
> This way, "myService" will receive an IN parameter called "newValue"
> which will be a GenericValue with the new field values for MyEntity
> entity instance.
>
>
>
> Regards,
>
>
>
> Francisco
>
>
>
> *Blurbiness multimedia*
>
> *www.blurbiness.com* <http://www.blurbiness.com>
>
>
>
> El mié., 3 jul. 2019 a las 11:54, Ingo Wolfmayr
> (<[hidden email]>)
> escribió:
>
> Hi everybody,
>
> I have a question regarding services :
>
> I hava a "eecas" that a service after a new OrderPaymentPreference has
> been created/stored.
>
> Within this service I would need some fields from OrderHeader entity.
> Unfortunately at this this point the entity entry is not commited and
> therefore I cannot query it. Is there a way to get those values. The
> service "storeOrder" is the service that initiates everything.
>
> I would appreciate every hint.
>
> Thanks,
> Ingo
>
>
>
> --
>
>
>


--



--
Atentamente,

El equipo de Blurbiness



*Blurbiness*
Producción multimedia para su negocio
*www.blurbiness.com* <http://www.blurbiness.com>

[hidden email]
Tel. +(34) 984 49 13 52

C/ San Guillermo, 8, bajo
33210 Gijón (Asturias)
España