Avatar of Alex Campbell
Alex Campbell
Flag for United States of America asked on

How to Search Table for Related Records in the Same Table

I have a table of documents. These documents come in, are reviewed, comments are posted and revised documents are posted.  All these documents should be in the same table.

Documents are named by Task Order and Document Type:

When I scroll on any of the documents with ABC-INTRO, I want to see the list of the other document names and their due dates in a portal.

Each record has a field called Task Order and Document Type so each record above has ABC-INTRO in the field.

Nothing is showing up in my portal.
FileMaker Pro

Avatar of undefined
Last Comment
Will Loving

8/22/2022 - Mon
Will Loving

I'm assuming that "ABC-INTRO" is the "Document Type"? The relationship needs to be a Self-Join relationship - meaning between two table occurrences of the same table. The Key field on both sides of the relationship will be whatever field holds the "ABC-INTRO" value. This must be an indexed field, so if you don't see "Indexed" next to it in the field list, check the Storage options under Settings.

Are you looking at the documents in List View with a portal to the related documents?
Will Loving

I copied this from your other question which I suggest you delete. Please be sure to post your response with the original question.

>  I should have mentioned this in the question, but I forgot that sometimes ABC can
> be later in the name. When I use ABC*, it also gets XYZ-ABC-001-01.
> When I use ABC*, I also get the ones with XYZ-ABC-001-01.

Unclear.  you indicated that you were not getting anything in the portal at all. If you want to have a key that can match ABC wherever it may appear in the string then you will need to make a calculated key that gives multiple values to match on such as "XYZ", "XYZ-ABC", "ABC", etc. You need to determine what values you do and don't want to see.

To clarify, please describe which values you want to match on
Alex Campbell

Sorry if that question about ABC sounded like it was about the portal. That is different. That is just a straight find for a field beginning with certain text.
I have accepted a solution for it.

To avoid that confusion, I am going to give some different examples.
Imagine that you are working with documents from different companies.
The companies are IBM and BP

The document types are Annual Report (AR) and Stock Filing (SF).
Each document type has different versions: 1, 2, 3, 4, etc.

So, the data would look like:

I have a calculated field that ends up with the company and the type of document, such as IBM-SF, BP-AR, etc.

If I go to IBM-SF-1, I would like to see in the portal: IBM-SF-2, IBM-SF-3, IBM-SF-4 because the portal will be returning IBM-SF records, but I don't need to see the current one.

Since I am on IBM-SF-1, I don't need to see that one.

If I go to IBM-SF-2, I would see IBM-SF-1,IBM-SF-3, and IBM-SF-4.

and so forth.

***Since the Company and Document Type field is calculated can I index on it***

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Will Loving

On the document side, you have a field already with the DocumentTypeVersion in it (IBM-AR-2). You need to also create a second calc field with just the DocumentType (IBM-AR)

On the viewing side there are several ways to do it depending on how you want to select/filter documents. The attached file shows one way which involves using two global fields that get set when you click on a larger list of documents (not shown in the example file). You could modify this to have a global field for Company and Report type and then filter the list of report using calculation fields as the key instead.

The point is that you need a two predicate relationship. The first part says "Match on the document type (e.g. "IBM-AR") and the second says DON'T match on the specifically selected document, e.g. (IBM-AR-2). This will give you all the ones except the currently selected.
Will Loving

The file did not upload. I'm trying again... document-select.fp7
Alex Campbell

Looked at DocumentView, but it listed 0/0 Found(Unsorted) and it did not allow me to move through records.
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Alex Campbell

Attached is a file that I created that actually does what I was looking for.
Alex Campbell

Actually, there is problem, with layout. Will correct and upload.
Alex Campbell

This one is correct.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Will Loving

Your file does the same thing and uses the same relationship technique that my example files does, the only difference is that you did it as a self-join to the same table. I did it with two tables because I assumed that you might be viewing the documents from a layout based on another table such as a contact record or an interface file that contained no real data at all.
Will Loving

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.