I use a similar technique all the time, and it works. I suspect something is amiss in your script. What exactly is your method for grabbing the key of the child record? Are you sure you're pointing it to the related field?
Thanks for responding. My script steps are Set Selection (oppnumberjoin:Opportunity number) then I set the variable to oppnumjoin:OpportunityNumber, then goto layout Active opportunities. The set selection is my downfall. My assumption is that would set the opp number to the opp number of the related record. I check my variable by doing a show message step. Should I use a different script step?
I've never used Set Selection for this purpose. It may be causing the problem. Set Selection is generally used (at least in my experience) for selecting a block of text inside a text field. What I normally do in this situation (where I want to grab the key field of a related record) is simply use Set Field (for a global field) or Set Variable (for, well, a variable) equal to the related key field:
Set Field [ gRelatedKey ; relatedTable::keyField ]
Set Variable [ $relatedKey ; relatedTable::keyField ]
Since the cursor is sitting on the related record when this step is executed, I've found it reliably grabs the right related record. No frills necessary.
I looked at the Set Selection script step and it is not the correct step. That is what I get working late at night or simply getting frustrated. The issue I have with set field is I have a global G_OppNO field in my OPPs.fp7 file, however I cannot choose it to set it. No need reply. You have me started down the correct road. Simply my error and getting back into the FMP swing...
I do not use any script. Do that:
The layout displays “Opportunity” table
The portal is related to “Opportunity” table 2 self-join with “Opportunity” table
Then define one of the field into the portal as button with “Go to related record” and parameters:
- Go to related record from ““Opportunity” table 2
- Show record using <current layout>
- Show only related record > Match current record only
The same for salesrep
Thanks. Maybe the documentation is incorrect, but it states the Get Related Record script step does not work with portals.
filemaker documentation is quite poor. I always make a try
be sure to use table 2 in the go to related record parameter
Thanks! Works like a champ. Beter than scripting.
One of the items I discovered, and believe was the real problem when using the Go To Related Record script step is that I had the button defined on the portal to the script to go to the opportunity from the Company tab. I then copied the script, renamed and modified accordingly to work from the SalesPerson tab. This fouled up the Company script and prevented it from working. So I deleted the copied Salesperson script and created a new one from scratch to work on the Salesperson tab. Voila.