Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Retreiving related records if they exist


Benny

Recommended Posts

I have two layouts. The first layout populates/retreives records from TableA. The second layout has 4 fields that are retreived from TableA and populates/retreives records from TableB. These two tables are related by an ID field that is defined as the relationship. I want to define a button that will go from the first layout to the second layout and retreive the related record if it exists. If there is not a related record (related by ID) I want to pull the 4 fields off of TableA and create a new record in TableB. I have the layouts created, but cannot come up with the script structure to perform this. I'm pretty new to the whole FileMaker thing. I'm using FM Pro 7. Any Ideas would be helpful. Thanks!

Link to comment
Share on other sites

  • 4 weeks later...

I've been racking my brain on the same thing. I use

set field(field::dbA; field::dbB)

go to related record (show only related records; from table "dbA"; using layout "dbB")

This works if the record already exists. If the related record does not exist, it wont go to the layout. I want to perform a check that if the related record exists, it goes to that related record on the second layout, if the related record does not exist, it creates a new record and populates a field. I can't seem to figure out the script command for the 'checking' function.

Link to comment
Share on other sites

Use something like this to check if related records exist:

 

If [ TableOccurenceName::RecordID ]

#Records exist in related table

Go to Related Record[ TableOccurenceName; Show only related records ]

Else

#Records don't exist in related table

End If

Link to comment
Share on other sites

No, if the related table has a record (with a record ID 0,) then

 

If [ TableOccurenceName::RecordID ]

 

evaluates to true, and it's safe to Go to Related Records[].

 

Of course, you could do the test with an IsEmpty() on the relationship instead, and just swap the If-Else branches.

Link to comment
Share on other sites

  • 2 weeks later...

I was able to figure this out after much work and frustration. If it exists I just go to related record. Else I copy the ID field and go to layout and create new record and past the id value. This seems to work. Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

Terms of Use