1 2 Previous Next 16 Replies Latest reply on Jul 20, 2017 11:41 PM by user19752

    getValueListTwoFields for related values only

    AnatoleBeams

      I have a php webpage that draws a ValueList for a drop-down list to select live projects from my database. In the database itself I have a similar layout that has the same function and the value list uses related fields to eliminate the projects that are not live. This works perfectly. However, the value list drawn from the database into the webpage remains blank unless I remove the "use related values only" setting in the Value List. Of course, then it lists all the projects and not just the live ones, but at least it proves that it works thus far.

       

      Any ideas why the getValueListTwoFields funtion does not seem to work with using related fields?

       

      many thanks - Anatole Beams

        • 1. Re: getValueListTwoFields for related values only
          databuzz

          Hi,

           

          Are you using a global field on the"left" side of the relationshiop to filter out just the live projects? If so this won't work in PHP due to the differences in how global fields work vs FileMaker Pro sessions.

           

          One thing to check.

           

          HTH,

          Andrew

           

          FileMaker 12/11/10/9/8 Certified Developer

          Databuzz

          - - - - - - - - - - - - - - - - -

          Phone: +61 2 9484 6565

          Mobile: +61 418 468 103

          Email: andrew@databuzz.com.au

          http://www.databuzz.com.au

          1 of 1 people found this helpful
          • 2. Re: getValueListTwoFields for related values only
            LyndsayHowarth

            You can, however, calculate those valuelistitems in a field that you can then do a foreach to get a valuelist...  you don't actually have to use the function.

             

            Obviously the easy thing to do is to make the global a standard field :-)

             

            - Lyndsay

            • 3. Re: getValueListTwoFields for related values only
              AnatoleBeams

              Yep - that could well be it. I'll have to think of another way of creating my live projects list.

              Thanks very much for that prompt response, Anatole

              • 4. Re: getValueListTwoFields for related values only
                databuzz

                If I know the number of records for the list will be relatively small I often just find the records by status etc then use that found set of records to generate the value list items.

                 

                Andrew

                • 5. Re: getValueListTwoFields for related values only
                  Fimano

                  Right. I have had that issue as well. In FileMaker, the related value setting works, because FileMaker instantly 'sees' the primary choice and thus can display the related values. A conditional value list is harder in php because the primary choice can not be determined unless you post it. Hope the explanation makes sense. I don't remember my exact solution, but I had do use some JavaScript to populate the second value list correctly. I'm pretty sure I concluded that conditional value lists "don't work" in php, so you might need to create a 'helper' php file that gets the primary choice, then connects to the database to get the corresponding values and return them to the calling file via JS.

                  Hope this helps,

                  Jens

                  1 of 1 people found this helpful
                  • 6. Re: getValueListTwoFields for related values only
                    AnatoleBeams

                    Thanks for your helpful comments.

                     

                    I just created a new field in FileMaker that listed the live projects only. This I am using for the live projects ValueList rather than the related record filter. Problem solved.

                     

                    It's always useful to discuss these issues as there are so many other options. But I also wanted to know if it was supposed to work - which it seems that it doesn't.

                     

                    Thanks again for everyone's responses, Anatole

                    • 7. Re: getValueListTwoFields for related values only
                      LyndsayHowarth

                      Fimano wrote:

                       

                      A conditional value list is harder in php because the primary choice can not be determined unless you post it.

                      Jens

                       

                      Yes... that is why using the field values work as you post the global value and pick up the resulting values in the field in the same call.

                       

                      There is another option which only works well when we are talking about small found sets... which is to filter using PHP... or better still using PHP and Javascript with jQuery. You can pull the entire set of records then filter dynamically in the page... saving further accessea of the server. You can store the record variable as a cookie which makes retreival very fast.

                      I use this in my calendars to quickly switch days / weeks / months /years and even AM/PM. In a medical Appointment system I built I also overlayed Operations vs Consultations and Hospitals.

                       

                      Glad you have this working...

                       

                      - Lyndsay

                      • 8. Re: getValueListTwoFields for related values only
                        davidrcrowe

                        As a test I took a value list that was supposed to show only values based on a relationship (which worked fine in a FileMaker client) and changed it to show all values. All of a sudden my code started working fine. Before it was returning an empty array.

                         

                        It's interesting that the second parameter, Record ID, is not documented in the FileMaker PHP API manual (although it is used in one example).

                         

                        It would be nice if they (A) documented the function and (B) described any limitations or circumstances under which it won't work.

                         

                        For me going to a static value list is a real pain in the neck. And in future examples it may be impossible

                         

                        - David

                         

                         

                         

                        $ValueList = $currentLayout->getValueListTwoFields($aValueList, $onerecord->getRecordId());
                        print_r($ValueList);
                        • 9. Re: getValueListTwoFields for related values only
                          user19752

                          In PHP, there is not a "current record".

                          So you need specifying record id as what is the current record, to get related value list.

                          • 10. Re: getValueListTwoFields for related values only
                            davidrcrowe

                            Is there something wrong with my code? I thought I specified the record ID as the second parameter.

                            • 11. Re: getValueListTwoFields for related values only
                              davidrcrowe

                              And further to my posting, I tried this with a test database, again accessed via the PHP API. A master table with a child linked by the serial number of the master, with a value list containing all the values in one field in the portal. So, Master Record = "Flower", Child records = "Rose", "Violet", "Lily". Master Record 2 = "Animal", Child records = "Cat", "Dog". If the relationship is constrained to show just the portal values it does not work (getValueListTwoFields returns an empty array) but if it shows all records (Rose, Violet, Lily, Cat, Dog), it works fine.

                              • 12. Re: getValueListTwoFields for related values only
                                user19752

                                No, your code may be correct (I can say only may be, since I didn't test it myself)

                                I tryed to do (B), when value list is "only related", there need base record.

                                • 13. Re: getValueListTwoFields for related values only
                                  davidrcrowe

                                  Further, further to my posting, I'm developing a PHP function that takes, among other things, the 'name' of a value list that may be:

                                   

                                  (A) the name of a FileMaker value list

                                   

                                  (B) the name of a FileMaker field containing a list of values

                                   

                                  (C) the name of a FileMaker field containing a list of (value + '|' + display text)

                                   

                                  (D) a static list of values separated by "|"

                                   

                                  The first 3 start with "@" just to distinguish them from the fourth. This allows me to have the benefits of FileMaker value lists that have a different value and display text while avoiding this nasty limitation of the FileMaker PHP interface. I can post the code when I finish debugging it if people are interested.

                                  • 14. Re: getValueListTwoFields for related values only
                                    fmdataweb

                                    I'm having the same issue - using getValueListTwoFields to get a value list that uses related values. Works fine in FileMaker Pro but returning an empty array in PHP. I'm using an unstored calc field in the parent/left part of the relationship to filter out records with a status of 'active' - not using a global field here.

                                     

                                    Is this supposed to work in this situation? I can't see any documentation that states otherwise. Changing it to show all values makes it work, but that's not the list of I want. I can do a find etc to generate the list manually but would like to use the native method where possible as it's less lines of code etc.

                                     

                                    Anyone able to get the getValueListTwoFields method to work with the PHP API when the value list uses related values?

                                    1 2 Previous Next