TRIRIGA

 View Only

 Question about how to make query section that shows only records of specific field value

HIROYA OGIHARA's profile image
HIROYA OGIHARA posted Wed August 06, 2025 10:06 AM
Rishabh Agarwal's profile image
Rishabh Agarwal

This is the feature of Query Section. You can retrieve and show the Players information inside Query Section which are belongs to Selected Team (on BaseballTeam Form). Just you need the Association String to show the associated players with the Team. Also here you can filter out the Player records based on Status of Players.

Mark Johnson's profile image
Mark Johnson IBM Champion

You should use an association between the BaseballTeam and the Baseball Player like "Has Player" and "Is Player For" for your forward and reverse association strings. 

What you want to do is build an advanced query on the BaseballPlayer BO. On the advanced tab you want to use the  $$RECORDID$$ and then you would set the information to the BaseballTeam BO and its association string to Baseball Player ("Has Player").  On the advanced tab you always go from what you know to what you want. Since the query section will be on the BaseballTeam form, that is what you know and what you want is the players. That's why the information you put in to the advance tab is for the BaseballTeam. You then put your query section on the BaseballTeam form. 

Unrelated to your question, in your example you use cstBaseballTeamidTX, and also cstBaseballTeamid2TX. I'd recommend against putting numbers in to your field names as it makes it harder to identify those fields in the T Table. Also, Field names are unique and you create them just once. You then can reuse that name on other objects, so you wouldn't need a separate field with the number 2 in it. You'd just find the field from the BaseballTeam with name that you want to reuse.

Hope that helps,

Mark

HIROYA OGIHARA's profile image
HIROYA OGIHARA

@Mark Johnson

Thank you so much.
 
We tried to use the associations you recommended. However still we don't get the player list we expects (Only players belonging to the team listed).
We added "Has Player" and "Is Player For" associations to the AssiociationTypes list of System and use them.
We created the following BOs:
Module:
     cstBaseballTeam
BO1:
     cstBaseballTeam (Parent)    Fields: cstBaseBallTeamidTX(Object Mapping Field),  cstBaseballTeamNameTX
BO2:
    cstBaseballPlayer    Fields: cstBaseballTeamidTX(We use cstBaseballTeamidTX instead of cstBaseballTeamid2TX as you recommended), cstPlayerNameTX, cstPlayerAgeNU
 
 
I posted the following screen captures related to association settings. I'd appreciate it if you check our settings are correct?
- Association of cstBaseballTeam 
Association Settings of cstBaseballTeam
- Association of cstBaseballPlayer
Association Settings of cstBaseballPlayer
- QuerySection of cstBaseballTeam form
QuerySection settings on cstBaseballTeam form
- Association Filter of Advanced tab ("Query - cstBaseballPlayer" that is used in the QuerySection)
Association Filter setting of cstBaseballPlayer query
Mark Johnson's profile image
Mark Johnson IBM Champion

One piece that we haven't discussed is that you need to associate the records before they would show up in the query section. What is the purpose of your query section, just to show the players on the team, or to be able to find players and add them to the team? So far what I shared with you would show the players associated to the team. If you want to add players, you'd want to create another query that just lists players, and then add that to the find action, and also have it call a workflow. In the workflow you would get the player, you'd want to find if they are already associated to another team, if so remove the association, and then associate the player to the new team. Then they would show up in your query.

There is another advanced query that you could do where on the system filter you'd use a parent filter on the cstBaseballTeamIdTX on the player record that points to the cstBaseballTeamIdTX field on the baseball team record. Look up the $$PARENT filter in the report manual to see the format and how it works.

One thing you'll find about TRIRIGA development, is there are usually multiple ways to do things. However, getting the right result is just one part of it as all ways are not created equal.

HIROYA OGIHARA's profile image
HIROYA OGIHARA

@Mark Johnson

Thank you for your reply and I'm sorry my response is late.
 
>What is the purpose of your query section, just to show the players on the team, or to be able to find players and add them to the team? 
 
The purpose of our query section is just to show the players on the team. We'd like to show the players that belong to the specific team without finding and adding players to the team.
For example, the following records exist:
 
BO1:  cstBaseballTeam
 Record:
      TeamA (cstBaseBallTeamidTX field="A")
      TeamB (cstBaseBallTeamidTX field="B")
BO2:  cstBaseballPlayer 
 Record:
      Player1 (cstBaseBallTeamidTX field="A")
      Player2 (cstBaseBallTeamidTX field="A")
      Player3 (cstBaseBallTeamidTX field="B") 
 
We'd like to show the players like below on our query section without finding and adding players to the team.
  - When TeamA is shown on the form, the following players should be shown on the query section:
      Player1 
      Player2
 
  - When TeamB is shown on the form, the following players should be shown on the query section:
      Player3
 
To achieve the query result above, I think we'd need an association between records. However we understand association is defined just between BOs.
How can we associate one record with another record by "association"?

Mark Johnson's profile image
Mark Johnson IBM Champion

Since you are not wanting to find and add players to the team and you just want to display the player records that have the same value as a field in the team record then you will need to use the $$PARENT filter. It will point to the cstBaseballTeamIdTX field on the team record. So your query will be just a simple query that displays player records, then you'll put the $$PARENT filter in to the system filters section.

"To achieve the query result above, I think we'd need an association between records. However we understand association is defined just between BOs.

How can we associate one record with another record by "association"?"

As far as associations go, there are 2 levels of association. There are BO Level associations which you define on the BO. These are how you define relationships between the objects. The 2nd level is Record Level associations. A record level association can exist whether it is defined at the BO Level or not. For instance, you can use an Associate Records task in workflow and associate any two records you want with any association string that you want provided you have a handle on those two records. 

Usually your association between the records would be set by adding the player record to your team record in the query section. With the approach that you are taking, an association is not required at all between the records, only that the team id fields match up on the team and player records.

--Mark

HIROYA OGIHARA's profile image
HIROYA OGIHARA
Thank you so much, Mark.
Thanks to your advices, I'm able to show Baseball Players in the Query Section as I expect now.
 
In addition to your advices, I learned the $$PARENT by the following document:
 
https://www.ibm.com/docs/en/SSHEB3_5.0/pdf/pdf_tap_report.pdf
 
This document says on P.25:
 
$$PARENT::SectionName ::FieldName$$ 
You can indicate a filter that compares a value in the record that is filtered with a value in the record that contains the smart section. To indicate that a value is compared with the FieldName field in the SectionName section of the record that contains the query section or smart section, use the following value field: $$PARENT::SectionName::FieldName$$.
When the value of the $$PARENT special value is empty, it resolves to an IS NULL criteria.
 
So I took the following approach using the SmartSection. Is my approach correct?
 
1.By the Data Modeler, I created the SmartSection (named cstBaseballShared) that has the "cstBaseBallTeamidTX" field in the cstBaseballPlayer BO.
2.By the Form Builder, I added the SmartSection (cstBaseballShared) to the form of the cstBaseballPlayer.
3.By the Report Manager, I added the system filter shown in the attached screen capture to the query of the cstBaseballPlayer.
I specified "$$PARENT::cstBaseballShared::cstBaseBallTeamidTX$$" in the Value field.
System filter settings of cstBaseballPlayer
 
I'd really appreciate it if you comment  on my approach.
 
- Ogi
Mark Johnson's profile image
Mark Johnson IBM Champion
This document says on P.25:
 
$$PARENT::SectionName ::FieldName$$ 
You can indicate a filter that compares a value in the record that is filtered with a value in the record that contains the smart section. To indicate that a value is compared with the FieldName field in the SectionName section of the record that contains the query section or smart section, use the following value field: $$PARENT::SectionName::FieldName$$.
When the value of the $$PARENT special value is empty, it resolves to an IS NULL criteria.
 
So I took the following approach using the SmartSection. Is my approach correct?
 
1.By the Data Modeler, I created the SmartSection (named cstBaseballShared) that has the "cstBaseBallTeamidTX" field in the cstBaseballPlayer BO.
2.By the Form Builder, I added the SmartSection (cstBaseballShared) to the form of the cstBaseballPlayer.
3.By the Report Manager, I added the system filter shown in the attached screen capture to the query of the cstBaseballPlayer.
I specified "$$PARENT::cstBaseballShared::cstBaseBallTeamidTX$$" in the Value field.
System filter settings of cstBaseballPlayer
 
I'd really appreciate it if you comment  on my approach.
 
You didn't need to create a smart section, the $$PARENT filter will work on a form section as well. You could just create the query section on the team form, and add the parent filter to point to the team id field on the team record. So, creating the smart section was all extra work that wasn't needed. So, if you changed the section and field information in your $$PARENT filter, to the form section and field on your form, it should also work.
--Mark
HIROYA OGIHARA's profile image
HIROYA OGIHARA

@Mark Johnson

Thank you, Mark.

>You didn't need to create a smart section, the $$PARENT filter will work on a form section as well. 

Yes, I verified the $$PARENT filter works on a form section as well. 

Thank you.

-- Ogi