Make sure the fields in the portal are from the same relationship as a portal. In inspector for a field "Display data from" part before :: has to be the same as the name at the bottom left of the portal (in layout mode).
I am not sure about "Multiple Values" in, can you explain where do you see it?
Thanks for the reply.
All but one field belongs to the same table, but I don't need that field. Here is a video showing the fields in the portal and the Multiple Values issue:
If that Flash doesn't show it clearly (or work) you can download the direct movie here:
As I mentioned above when I get a record for this portal and call getFields(), I only get this back (using print_r on the portal record object):
Array (  => Quotations::LineItemAdditionalInfo  => Quotations::LineItemName  => Quotations::ItemQuantity  => Quotations::LineItemAdditionalInfo2 )
The only field in that array that I see is in the portal layout is LineItemName, I'm very confused as to why it's showing these other fields that aren't in the layout, and not showing the actual fields that are in the layout.
Thanks for the video.
When you select LineItemName it appears as Quotations::LineItemName. Quotations is the name of the relationship the portal is based on. It is the same name you can see on the portal bottom left corner.
The reason you see Multiple Values is because you have multiple fields stacked on top of each other and grouped. If you ungroup them you will see the fields from you array. I am still suspicious why you are not getting couple of calc fields values.
I would suggest removing all fields from the portal and off the layout and adding them one by one making sure the relationship is correct. Also try to make portal row bigger and make sure field boundaries are within the portal row.
In any case, which field value you are getting and which one you are trying to get?
Ah, that grouping makes sense now that I see it.
I found the problem! There are multiple Quotations portals on this layout, and the one that getRelatedSet() is pulling is the first one in the layout (hidden behind layers of tab controls), not the actual portal I want. Now it all makes perfect sense.
Now for a new problem: how to get the PHP API to pull this specific portal I want? Using this code it only shows a single entry for "Quotations":
$lay = $fm->getLayout('MyLayout'); print_r($lay->listRelatedSets());
I may have to go directly to the XML API...
I was going to suggest checking this as the next step.
I don't think you can chose which portal to retrieve if they are based on the same table occurrence.
What stops you from adding the field you need to get to the portal you are getting now? They are from the same relationship on the same layout, so you will get the same result.
Another workaround is to create another table occurrence, a duplicate of Quotations and call it differently, e.g. Quotations_php. Make sure the relationship predicates are the same, create a portal based on the new TO and retrieve data from there. Does this make any sense?
I would like to avoid modifying the layout in any way.
After poking in the XML file I verified that multiple related sets with the same name are actually returned, so it's just the PHP API that is lacking.
I found an alternative API https://github.com/soliantconsulting/SimpleFM which also didn't support this feature, but I was able to patch it (https://github.com/soliantconsulting/SimpleFM/pull/56). It's still a little hackish in that you need to look at the keys for the portal record to identity which portal it is, and that may not always be perfect. SimpleFM also has a "portalindex" value it sets internally which you could use too. Either way, the data is at least accessible.
Now, after that massive detour, back to what I was actually trying to accomplish . Thanks for your help nicolai!
Glad you managed to find a solution. Just one more thing before you go - it sounds like you get data from the end-user facing layouts in FileMaker. The common practice is to generate separate set of layouts for php use only.
I can see the advantage of that due to performance, but what about duplicate logic with scripts, or formatting?