Shift Data from one column to another within a Child BO

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: 24
Joined: Thu Jun 25, 2020 12:23 pm

Shift Data from one column to another within a Child BO

Post by JHew »

I have a parent and child business objects, LabourReviewProductCell (Parent) and LabourReviewAllocation (Child). In the Child BO users add records of people and then allocate X amount of hours for the next three weeks. This is set up by having three different columns to represent the current and next two weeks: Week0, Week1, and Week2. At the start of each week I need the system to automatically “shift” the hours to its proceeding column so that the data is always kept up to date.

I thought that this would be reasonably simple, as I could just use a process to say BO.Week0 = BO.Week1, BO.Week1= BO.Week2 and so on and run this every Monday morning. But for some reason this is acting differently to how I would expect; When I call the process, it will take the last value of the record entered and update all of the other records with this value.

Has anyone done anything similar to this and got it working?

Process
Find ALL LabourReviewAllocation

LabourReviewAllocation.AllocatedHoursWeek0 = LabourReviewAllocation.AllocatedHoursWeek1
LabourReviewAllocation.AllocatedHoursWeek1= LabourReviewAllocation.AllocatedHoursWeek2
LabourReviewAllocation.AllocatedHoursWeek2 = 0
Attachments
Capture.PNG
Capture.PNG (6.12 KiB) Viewed 340 times
PointsWell
Posts: 1280
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Shift Data from one column to another within a Child BO

Post by PointsWell »

What you process does is bring ALL of your records into Context and then change all of the values to the value of one arbitrary record. AIM can't build edit multiple records to multiple different values.

If you want to make each individual record be modified then you need to pass these to a second process individually.

Process 1

Code: Select all

Process
Find ALL LabourReviewAllocation
UpdateRecords
Process 2: UpdateRecprds
Input LabourReviewAllocation

Code: Select all

LabourReviewAllocation.AllocatedHoursWeek0 = LabourReviewAllocation.AllocatedHoursWeek1 
LabourReviewAllocation.AllocatedHoursWeek1= LabourReviewAllocation.AllocatedHoursWeek2
LabourReviewAllocation.AllocatedHoursWeek2 = 0
This second process will receive exactly one record process the updates then cycle through the next record until all of the records from the FIND are completed, before moving on to any subsequent processes.

The process you used originally is good for instance when you want to change all of the records to one value, for example changing all of the Accounts in a system to have a new SalesAssociate.
eagles9999
Posts: 2279
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Shift Data from one column to another within a Child BO

Post by eagles9999 »

Alternatively (But not recommended as it is slower)

Find ALL LabourReviewAllocation IN BATCHES OF 1
Cheers,
Mark
_________________
AwareIM 6.0, 8.6, 8.7 (build 2941) MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Chrome, Edge
Upcloud
Image
JHew
Posts: 24
Joined: Thu Jun 25, 2020 12:23 pm

Re: Shift Data from one column to another within a Child BO

Post by JHew »

Thank you, its working perfectly now!

I did try something similar to this before, but I put 'IF SEARCH_COUNT > 0' at the beginning of the second process which made it not work.
PointsWell
Posts: 1280
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Shift Data from one column to another within a Child BO

Post by PointsWell »

JHew wrote: Tue Aug 16, 2022 7:34 am Thank you, its working perfectly now!

I did try something similar to this before, but I put 'IF SEARCH_COUNT > 0' at the beginning of the second process which made it not work.
If you want to improve efficiency and not run the process when there are no records returned from the search then

Process

Code: Select all

Find ALL LabourReviewAllocation
IF SEARCH_COUNT >0 THEN UpdateRecords
Post Reply