cancel
Showing results for 
Search instead for 
Did you mean: 

RAP: How to access child information while being on parent entity?

Kinsbrunner
Active Contributor
0 Kudos

Hi colleagues,

Currently working on a Composition structure (Parent/Child) where I would need, based on a non-key field of the parent, to check whether a child is present or not. Currently, I am not seeing any straight forward way to see this as on the Create of the behavior implementation class, I only have access to parent data and, when standing on the CBA_Child, I only see the parent's key.

Answer is not as simple as "read through EML" as currently working with legacy FMs which is becoming a nightmare.

So far, the solution I could think of is to have a custom buffer which gets filled in on the Create and CBA_Child methods and, finally, gets checked on the CHECK_BEFORE_SAVE method. If I do not get there with the expected outcome, I can fill in the FAILED structure for the main entity and that will stop the commit.

Althought I believe this solution could work, it is not really efficient as I am doing all the process and only stopping before saving while, if I would be able to make the check on the handler class, I would avoid all this processing.

Has anyone experienced a similar issue?

Any advice from our experts @Andre_Fischer or @Renzo ? 🙂 

Thanks in advance! 

Alejandro.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Alejandro,

I assume that you are using an unmanaged implementation? What about draft enabling the same. This way you should be able read the data via EML.

Or what about using a managed implementation with draft and unmanaged save?

Kind regards,  

Andre

View Entire Topic
Kinsbrunner
Active Contributor
0 Kudos

Hi Andre, just found your comment.

Yes, I am using an Unmanaged implementation. We do not want to use Draft as per business requirements.

So far, I have created a custom buffer where I log once every header entity that is created and update it if a child is also created. Finally, I validate the buffer content on the check_before_save and delete the entry from the buffer. So far, it is working. Yet, wanted to know whether there is a nicer approach that could be taken?

Regards.

Alejandro.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
I don't understand why one wants to implement a buffer if you get this for free by using draft.
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
The nicer approach is to use draft since it is part of the standard. '
Kinsbrunner
Active Contributor
0 Kudos

Thanks for your answer Andre!

The reason why I would not like to use the Draft feature is because I do not want to persist the buffer data nor to have the need of creating an additional DB table.

My buffer class is written on the same class where I have my behavior implementation and it just has a table with the 3 fields I need (ID of parent, a flag for marking that certain child is needed and another flag for confirming that the child is present). I append an entry when creating the father and mark the second flag upon the creation of the child. Finally, I check on the check_before_save that for each registry on the buffer table, both flags are marked, if not, raise an error and do not save.