Loop thru BO records for process

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Loop thru BO records for process

Post by KnightWare »

How would I loop thru all records in a BO, and run a process for each. I don't need to check each record, I just need the data from the current context in a process. When the process returns, onto the next record until all records have been run thru. I don't need to update the records, although I could I guess.

For Each BO Record
Start Process DoSomethingWith Current BO
Next BO Record
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

KnightWare wrote: Wed Jan 06, 2021 6:57 pm How would I loop thru all records in a BO, and run a process for each. I don't need to check each record, I just need the data from the current context in a process. When the process returns, onto the next record until all records have been run thru. I don't need to update the records, although I could I guess.

For Each BO Record
Start Process DoSomethingWith Current BO
Next BO Record
Process 1
Find all relevant records
If SEARCH_COUNT >0 then Run Process 2

Process 2 (input the BOs found in process 1j
Do whatever you are trying to achieve

What will happen
Process 1 will find 'n' records where n>= 0
Process 2 will receive BOs one at a time and process each BO instance to the end of whatever process hierarchy exists in and under process 2
As it finishes with the first BO is will go back to the start of Process 2 with the next BO in context until all BOs have been processed.

As long as you don't have a DISPLAY (of either a BO or a query result) then once you've processed all of the Process 2 looped activities control will revert back to Process 1 where you can carry on with other additional processing
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Loop thru BO records for process

Post by KnightWare »

Seems to be only operating on 1st BO record.

Process 1
FIND BO where BO.PID > 0
START PROCESS Process 2

process 2 with BO as input
Execute Program program_name BO.Field
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

KnightWare wrote: Wed Jan 06, 2021 9:43 pm Seems to be only operating on 1st BO record.

Process 1
FIND BO where BO.PID > 0
START PROCESS Process 2

process 2 with BO as input
Execute Program program_name BO.Field
I am assuming that you definitely have more than on BO where BO.PID>0

Test it first with a process that doesn't call a program, for example set a timestamp field or set a flag. It definitely works. The issue may lie with the EXECUTE PROGRAM.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Loop thru BO records for process

Post by KnightWare »

Yes there are 25 records that would be found.
Same - only updates the first record.


Process 1
FIND BO where BO.PID > 0
START PROCESS Process 2

process 2 with BO as input
BO.PROCESS_DATE = CURRENT_TIMESTAMP
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

KnightWare wrote: Wed Jan 06, 2021 10:27 pm Yes there are 25 records that would be found.
Same - only updates the first record.


Process 1
FIND BO where BO.PID > 0
START PROCESS Process 2

process 2 with BO as input
BO.PROCESS_DATE = CURRENT_TIMESTAMP
You need to post an example - it definitely works.
ACDC
Posts: 1141
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Loop thru BO records for process

Post by ACDC »

Yes there are 25 records that would be found.
Same - only updates the first record.
have you tried adding "IN BATCHES OF 1 " in your FIND process
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

ACDC wrote: Thu Jan 07, 2021 7:58 am
Yes there are 25 records that would be found.
Same - only updates the first record.
have you tried adding "IN BATCHES OF 1 " in your FIND process
That shouldn't be necessary
ACDC
Posts: 1141
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Loop thru BO records for process

Post by ACDC »

That shouldn't be necessary
I would be very interested to see how you would do it otherwise
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

ACDC wrote: Thu Jan 07, 2021 8:52 am
That shouldn't be necessary
I would be very interested to see how you would do it otherwise
You do it as I described above.
ACDC
Posts: 1141
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Loop thru BO records for process

Post by ACDC »

You do it as I described above.
Yes , but he says it doesn't work:
Yes there are 25 records that would be found.
Same - only updates the first record.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Loop thru BO records for process

Post by PointsWell »

ACDC wrote: Thu Jan 07, 2021 9:33 am
You do it as I described above.
Yes , but he says it doesn't work:
Yes there are 25 records that would be found.
Same - only updates the first record.
Which is why I asked him to provide an example that I can look at.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Loop thru BO records for process

Post by KnightWare »

Whats the best way to supply the example?
Screen shots of the process's?

Updates first record in External SQL table, not all of them.

BO is Called DIRT, PID is a numeric record ID
DIRT.PID > 0 should return all records. There are 25.
---------------------------------------------------------------------------------------------

Process #1 (RefreshAll)
ForAllDirt
FInd DIRT where DIRT.PID > 0
Start Process 'UpdateDate'

Process #2 (UpdateDate) with BO DIRT as Input
SetDate
DIRT.PROCESS_DATE=CURRENT_TIMESTAMP
----------------------------------------------------------------------------------------------
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Loop thru BO records for process

Post by BobK »

PointsWell wrote: Wed Jan 06, 2021 9:52 pm Test it first with a process that doesn't call a program, for example set a timestamp field or set a flag. It definitely works. The issue may lie with the EXECUTE PROGRAM.
I totally agree with PointWell that this works.

Have you looked at the AwareIM main.log?

To see how much DIRT the process 1 is actually finding, look for lines something like

Code: Select all

Executing action FIND DIRT where DIRT.PID > 0
Found 25 objects
To verify each record is being passed to Process 2, look for a line something like

Code: Select all

Executing process UpdateDate with parameters: DIRT:1
The number at the end is the DIRT.ID of the record being passed to the process and there should be a line like this for each time process 2 is called.
Bob
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: Loop thru BO records for process

Post by KnightWare »

Looking at wrapper.log (AwareIM\Logs\Wrapper.log) i do not see anything entered as you show. I am running in test mode. I do see entries for errors when I accidentally named the process wrong. But nothing after I corrected.
Post Reply