[Solved] Find records with the same identifier that exist the same BO and update the other records

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
JHew
Posts: 27
Joined: Thu Jun 25, 2020 12:23 pm

[Solved] Find records with the same identifier that exist the same BO and update the other records

Post by JHew »

I have a business object where users will change the dates of a field using inline editing within a query. Some of these records will also have related records in the same BO, which will also needed to be updated if a user makes a change. Whist these are related, they still need to act as individual records 99% of the time therefore cant be set up as parent & child.

I have a rule in the business object that manages the first part, so if a user makes a change, and the record has related records (Main_Planning_Data.SubAssembly=0 ), it sets the value that all the related records need to be to field Main_Planning_Data.SubAssemblyDate.

Code: Select all

If Main_Planning_Data.ProductionDate WAS CHANGED  AND Main_Planning_Data.SubAssembly=0 Then 
 Main_Planning_Data.SubAssemblyDate=Main_Planning_Data.ProductionDate-2

PlanSubAssemblies
Where I’m struggling, is understanding how to get the context correct so that the system knows to update the values of the related records. I’ve attempted this in the sub process (PlanSubAssemblies) that runs and have tried to use “This” to get the context right but it’s not working.

PlanSubAssemblies

Code: Select all

FIND Main_Planning_Data WHERE  ThisMain_Planning_Data.SubAssemblyID=Main_Planning_Data.SALES_ORDER
IF SEARCH_COUNT > 0 Then Main_Planning_Data.ProductionDate = ThisMain_Planning_Data.SubAssemblyDate
Does anyone know where I’m going wrong?

Thanks.
Last edited by JHew on Thu Jul 14, 2022 11:15 am, edited 1 time in total.
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Find records with the same identifier that exist the same BO and update the other records

Post by hpl123 »

I find your description a bit difficult to understand but when it comes to the context question, here are some thoughts that might help.

If you have a particular MainObject instance and you need to find and update a list of related MainObjects instances with a value from that particular MainObject instance (from a business rule), a rule like this would do that:
FIND MainObject WHERE .....
OtherMainObject.Attribute=ThisMainObject.Attribute

What the "This" context prefix does in this situation is selects/uses the first of the MainObject instances in context (i.e the MainObject from which the rule was executed), the "Other" context prefix selects/uses all other MainObject instances.
Henrik (V8 Developer Ed. - Windows)
JHew
Posts: 27
Joined: Thu Jun 25, 2020 12:23 pm

Re: Find records with the same identifier that exist the same BO and update the other records

Post by JHew »

Thanks, that worked perfectly. I wasnt even aware the "other" prefix existed!
Post Reply