perform process on BO_B Based on Query Results of BO_A

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

perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

Can I process each record of a BO, based on the records found in a query of another BO? SO the process would be to Run a query of BO_A and filter down to the records you want. Each of these records contain a key field. Now based the this query results, find records in a second BO_B where BO_B. Key_field = BO_A.Key_field and set another field in BO B.

BO_A.Key_Field
BO_A.Description
BO_A.System
BO_A.Account

BO_A.Key_Field
BO_B.Category


Query BO_A and filter down to the records you want by Description, System, Account ect. Now using the results find each record in BO_B wher the Key Fields match and set the Category in BO_B to some value.

I've managed to pass the filtered BO_A to a process. FInd BO_B based on the key field and update the category. but only for the first record. Not all the records in the passed query results.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: perform process on BO_B Based on Query Results of BO_A

Post by PointsWell »

Your example is very abstract, so it's difficult to understand what's going on.

Are you trying to achieve all of this in a single process? If so then the behaviour that you've described is as expected.

If you have a set of found records and then want to process those against another set of records you need to create a second process with an input of the results of the first query

Example

ProcessFindBOA

Code: Select all

Find BOA where BOA.System='XYZ'
ProcessUpdateBOB
ProcessUpdateBOB input BOA

Code: Select all

Find BOB where BOB.Key=BOA.System
BOB.Attribute ='123'
Last edited by PointsWell on Wed Jun 16, 2021 11:02 pm, edited 1 time in total.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

On the right track, I did separate the processes. But the first step is actually running a query and letting the user filter it down to the records they want. So I have the query results on the screen with a button in the tool bar to start the process. I do input the BOA of the query.
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: perform process on BO_B Based on Query Results of BO_A

Post by PointsWell »

A better example or the actual code would be helpful as it's not clear what you are doing.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

I'll try to draw it up, but basically - you run a query and

1. You run a query against BOA. The user uses that query to filter down to the group of records they want.
2. You want to set a field in another Business Object (BOB) based on this group using the OBJECT_ID (Key field) that is in both BO's.

How I have it setup.

Run BOA Query and continue to filter to the desired group. this will be the Objects Identifiers you want to update in the second BO.
In the tool bar select "RECLASS" button that starts process "Reclass" with input BOA.

Reclass Process (input BOA).
Rule 1. Open form to store the Category value you want to set in the LoggedInRegularUser.CATEGORY attribute.

Rule 2 action 1. FIND BOB WHERE BOB.OBJ_ID=BOA.OBJ_ID
Step 2 action 2. BOB.CATEGORY=LoggedInRegularUser.CATEGORY

This works, but only for the first record of BOA.
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: perform process on BO_B Based on Query Results of BO_A

Post by Jaymer »

this is the typical issue...

either add "IN BATCHES OF 1" to the FIND BOB (slower)
OR call a subprocess with input BOB to receive the pointers of the found BOBs, and apply the update there
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: perform process on BO_B Based on Query Results of BO_A

Post by BobK »

Looks like a bug to me.

I believe the following is similar to what KnightWare describes

I have a query that finds some A records.
This query has a "Panel Operation" that Starts Process "CountKeys" and "Applicable to multiple items" is selected.

I run the query and filter the results to get the desired A records.
After selecting 2 records I execute the "Panel Operation" that starts the process "CountKeys"

Here is the code for the CountKeys Process (which has A as input):

Code: Select all

FIND B WHERE B.KeyID=A.KeyID
INCREASE B.CountKeys BY 1

Here is the logs from executing the CountKeys process:
-20 Executing process CountKeys with parameters: A:3A:4
-29 Started evaluation of rules
-22 Evaluating rule 'FindB' FIND B WHERE B.KeyID=A.KeyID
-2 Adding action FIND B WHERE B.KeyID=A.KeyID to the agenda
-16 Finished rule evaluation
-16 Finished evaluation of rules
-15 Executing action FIND B WHERE B.KeyID=A.KeyID
-33 Found 1 objects
-16 Finished executing action FIND B WHERE B.KeyID=A.KeyID
-25 Started evaluation of rules after data has been changed by the actions
-6 Checking rule FindB
-16 Finished evaluation of rules after data has been changed by the actions
-29 Started evaluation of rules
-22 Evaluating rule 'IncreaseCount' INCREASE B.CountKeys BY 1
-2 Adding action INCREASE B.CountKeys BY 1 to the agenda
-16 Finished rule evaluation
-16 Finished evaluation of rules
-15 Executing action INCREASE B.CountKeys BY 1
-4 CountKeys=1

-30 Starting execution of rules when updating business object B 6
-29 Started evaluation of rules
-22 Evaluating rule 'Initial value for B.CountKeys' If B.CountKeys IS UNDEFINED Then B.CountKeys=0
-6 Evaluating condition B.CountKeys IS UNDEFINED
-7 Condition evaluated to false: 1
-16 Finished rule evaluation
-16 Finished evaluation of rules
-16 Finished execution of rules when updating business object B 6
-16 Finished executing action INCREASE B.CountKeys BY 1
-25 Started evaluation of rules after data has been changed by the actions
-6 Checking rule IncreaseCount
-16 Finished evaluation of rules after data has been changed by the actions
-16 Finished executing process CountKeys
Notice that two A records are passed into the process, but only one is processed.
Bob
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: perform process on BO_B Based on Query Results of BO_A

Post by BobK »

I still think it is a bug, but here is a work around.

I assume you have a ReClass operation on you query. If so, remove it because it is no longer needed.

Create a new process with the first rule as
PICK ONE OR MORE FROM <the name of your existing query>
The next rule would be
ReClass


When you run this new process, your existing query will run and you can do any filtering that is needed.
Select the required records in the query and press the "continue" button.
The ReClass process will be executed for each selected records.
Bob
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: perform process on BO_B Based on Query Results of BO_A

Post by BobK »

KnightWare wrote: Thu Jun 17, 2021 4:42 pm I'll try to draw it up, but basically - you run a query and

1. You run a query against BOA. The user uses that query to filter down to the group of records they want.
2. You want to set a field in another Business Object (BOB) based on this group using the OBJECT_ID (Key field) that is in both BO's.

How I have it setup.

Run BOA Query and continue to filter to the desired group. this will be the Objects Identifiers you want to update in the second BO.
In the tool bar select "RECLASS" button that starts process "Reclass" with input BOA.

Reclass Process (input BOA).
Rule 1. Open form to store the Category value you want to set in the LoggedInRegularUser.CATEGORY attribute.

Rule 2 action 1. FIND BOB WHERE BOB.OBJ_ID=BOA.OBJ_ID
Step 2 action 2. BOB.CATEGORY=LoggedInRegularUser.CATEGORY

This works, but only for the first record of BOA.
I just reread this.

Is the user really doing a EDIT or VIEW to look at the BOA data?
If Yes, my work around does not work. I am not even sure it can be done.
Why are you looking at it? Are there multiple Categories and the user has to pick 1??
Bob
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

The PICK ONE OR MORE... Displays the query, but just a close button, no Continue.
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: perform process on BO_B Based on Query Results of BO_A

Post by BobK »

KnightWare wrote: Thu Jun 17, 2021 10:18 pm The PICK ONE OR MORE... Displays the query, but just a close button, no Continue.
No Continue hmmm.

I don't know.
Bob
rocketman
Posts: 1239
Joined: Fri Jan 02, 2009 11:22 pm
Location: Preston UK
Contact:

Re: perform process on BO_B Based on Query Results of BO_A

Post by rocketman »

KnightWare wrote: Thu Jun 17, 2021 4:42 pm I'll try to draw it up, but basically - you run a query and

1. You run a query against BOA. The user uses that query to filter down to the group of records they want.
2. You want to set a field in another Business Object (BOB) based on this group using the OBJECT_ID (Key field) that is in both BO's.

How I have it setup.

Run BOA Query and continue to filter to the desired group. this will be the Objects Identifiers you want to update in the second BO.
In the tool bar select "RECLASS" button that starts process "Reclass" with input BOA.

Reclass Process (input BOA).
Rule 1. Open form to store the Category value you want to set in the LoggedInRegularUser.CATEGORY attribute.

Rule 2 action 1. FIND BOB WHERE BOB.OBJ_ID=BOA.OBJ_ID
Step 2 action 2. BOB.CATEGORY=LoggedInRegularUser.CATEGORY

This works, but only for the first record of BOA.
If the category is the same for all the selected group of BOA'a then try this (you don't need a reclass button)

Process 1
Enter new [Non Persistent Business Object] (allows user to enter a Category in an NPBO attribute of the correct type)
PICK ONE OR MORE FROM [Some Query]
Process 2

Process 2 (input NPBO, BOA)
FIND BOB WHERE BOB.OBJ_ID=BOA.OBJ_ID
BOB.CATEGORY=NPBO.[Attribute containing the category]
Rocketman

V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

Rocketman - pretty much exactly how I have it set. I am storing the value in an attribute of LoggedInRegularUser.Category. I did not pass that along because I thought it was persistant, so always available. Let me check this out.
KnightWare
Posts: 139
Joined: Sat Feb 10, 2018 12:56 am

Re: perform process on BO_B Based on Query Results of BO_A

Post by KnightWare »

When using the "PICK ONE OR MORE FROM Query", the query is all screwed up. Columns all out of order and some missing. You have to check every row as there is not a select all. And then that doesn't work, check a second box and the first one disappears and so on. You can only select one at a time.
rocketman
Posts: 1239
Joined: Fri Jan 02, 2009 11:22 pm
Location: Preston UK
Contact:

Re: perform process on BO_B Based on Query Results of BO_A

Post by rocketman »

Are you using a previously created query?

Create a query let’s say we call it queryboa

Set the displayed columns, groups, filters etc as you normally would.

Then the line is:
Pick One or more from queryboa

If this doesn’t work, there’s a bug or corruptionin the version you are using - try a re-install
Rocketman

V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Post Reply