Jump to content

Creating an array in PHP from a Value List in Filemaker


Jack Wright
 Share

This topic is 1843 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello!

Another post...

Please help me out.

I am trying to create an array from a value list within Filemaker Pro (Using PHP API)

The idea is to create an array of names from a value list I have set up... Then put them into an option tag.

e.g.

$staff = array(FileMaker Value List)
^^ I know that's incorrect, but it shows what I want to do

Then with that array I want to be able to Create a HTML option list (I know how I would do that)  ---  I am just really struggling with creating the array...

Here is what I have

 

$database = "comms__web";
    $hostname = "###.###.#.#";
    $username = "web";
    $password = "################";
    
    $layoutname = "Web";
    $valueListName = "MIS";
        //CREATE FILEMAKER OBJECT

        $fm = new FileMaker($database, $hostname, $username, $password);

    //GET THE LAYOUT AS AN OBJECT.

    $layoutObject = $fm->getLayout($layoutName);
 

    //GET THE VALUE LIST

    $valueList = $layoutObject->getValueList($valueListName);

 

However it doesn't actually appear to pick up the list...

Please help me out :) 

Thanks,

Edited by Jack Wright
Link to comment
Share on other sites

You could inspect what is returned on the layout with print_r($layoutObject) and see what is in there. The value list must be associated with the field on that particular layout.

And what version of FMS are you working with? I believe that function may also be deprecated. Have you tried getValueListTwoFields instead?

Link to comment
Share on other sites

25 minutes ago, Mike Duncan said:

You could inspect what is returned on the layout with print_r($layoutObject) and see what is in there. The value list must be associated with the field on that particular layout.

And what version of FMS are you working with? I believe that function may also be deprecated. Have you tried getValueListTwoFields instead?

I am using FMS 14

Additionally 

The layout has a field on it with the valuelist assigned to it.

Nothing showed up with the print_r 
 

Link to comment
Share on other sites

Seems like you are missing the FIELD object:

//CREATE FILEMAKER OBJECT
$fm = new FileMaker($database, $hostname, $username, $password);

//GET THE LAYOUT AS AN OBJECT.
$layoutObject = $fm->getLayout($layoutName);

$fieldName = "your_field_name';

//GET THE FIELD FROM LAYOUT AS AN OBJECT
$fieldObject = $layoutObject->getField($fieldName);

//GET THE VALUE LIST ATTACHED TO THIS FIELD
$valueList = $fieldObject->getValueList();

// FOR TESTING
echo "<pre>";
print_r($valueList);
echo "</pre>";

Good luck!
Link to comment
Share on other sites

On 7/13/2016 at 4:54 PM, dwdata said:

Seems like you are missing the FIELD object:

//CREATE FILEMAKER OBJECT
$fm = new FileMaker($database, $hostname, $username, $password);

//GET THE LAYOUT AS AN OBJECT.
$layoutObject = $fm->getLayout($layoutName);

$fieldName = "your_field_name';

//GET THE FIELD FROM LAYOUT AS AN OBJECT
$fieldObject = $layoutObject->getField($fieldName);

//GET THE VALUE LIST ATTACHED TO THIS FIELD
$valueList = $fieldObject->getValueList();

// FOR TESTING
echo "<pre>";
print_r($valueList);
echo "</pre>";

Good luck!

Thank You!

Will try this out when I am next on the computer!

Link to comment
Share on other sites

This topic is 1843 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Similar Content

    • By ggt667
      Is there a way to query CWP using FMPXMLRESULT as payload to create new records in FileMaker? Goal is to be able to insert records from command line using curl from FMPXMLRESULT files to avoid a somewhat clunky query from FileMaker XML import.
      I tried the following:
      cd /tmp/ curl -X POST -kL -o /tmp/findany.fmpxmresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-findany" curl -X POST -kL --data @findany.fmpxmlresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-new" A new record is created, however the payload is ignored.
      Payload below FTR
      <?xml version="1.0" encoding="utf-8" standalone="no"?><!DOCTYPE FMPXMLRESULT PUBLIC "-//FMI//DTD FMPXMLRESULT//EN" "http://127.0.0.1/fmi/xml/FMPXMLRESULT.dtd"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="03/16/20" NAME="FileMaker Web Publishing Engine" VERSION="18.0.4.428"></PRODUCT> <DATABASE DATEFORMAT="MM/dd/yyyy" LAYOUT="Table" NAME="PushTest" RECORDS="17" TIMEFORMAT="HH:mm:ss"></DATABASE> <METADATA> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="number" TYPE="NUMBER"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="date" TYPE="DATE"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="timestamp" TYPE="TIMESTAMP"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="time" TYPE="TIME"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="_global" TYPE="TEXT"></FIELD> </METADATA> <RESULTSET FOUND="1"> <ROW MODID="13" RECORDID="24"> <COL> <DATA>Sweet</DATA> </COL> <COL> <DATA>667</DATA> </COL> <COL> <DATA>06/05/2020</DATA> </COL> <COL> <DATA></DATA> </COL> <COL> <DATA>10:44:15</DATA> </COL> <COL> <DATA></DATA> </COL> </ROW> </RESULTSET> </FMPXMLRESULT> If I simply put the parameters after the "?" in the payload file it works, however INSERTing the actual FMPXMLRESULT would be desirable.
      curl -X POST -kL --data @/tmp/GETlike.txt "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml" Where /tmp/Getlike.txt contains
      -dbnames as pr example returns expected list of database names.
    • By John Link
      I have a field named "Databases" with the following values: "CORD", "SDHS", "Y Ballet". This field is displayed as a checkbox set. I recently learned that "CORD" should have been "DSA", so I naively changed "CORD" to "DSA" in the value list but then none of the records that were checked for "CORD" were checked for "DSA", which reminded me that the values in the value list are the values of the field Databases and not labels for checkboxes. I revised the value list to again include "CORD" and its checkbox is again checked for all the records for which it was originally checked.

      I wrote a script, shown in one of the attachments, to insert "DSA" into the Databases field for each of the records that contains "CORD" in that field. When I run the script I get an error message saying "Databases" is defined to contain only specific values, and that I must enter a valid value. How can DSA not be a valid value when it is included in the value list for the field? How can I accomplish what I want to do?

      Does programming scripts in FileMaker ever get easier? I don't write many scripts, but when I do I find it surprisingly difficult to accomplish what I think would be the simplest of tasks.

      Thanks in advance for your help,
      John Link


    • By Tony Diaz
      The tables.
      Items::ID
      Items::Item
      Items::Publisher
      Items::Date
       
      The Genre data is already arranged like this:
      Genre::ID (Unique Key)
      Genre::Name
      Genre::Category_ID
      Genre::Category

      The Platform data is 'simple'. ID and Name. But each item could be multiple platforms.  (Example #1 vs. Example #2)
      Platforms::ID
      Platforms::Name
      An item can have multiple Genre Categories related to it, and those usually have a single choice from within their Category, but might have multiples.

      It's supporting the possible multiples that I'm trying to work out. At this point there's 15 possible Genre Categories that each Item could have a selection from. Most have 4-6 of them.

      Example 1: Items::Table on the left, Genre::Table on the right, with some Genre Categories (Genre, Perspective, Pacing, Gameplay, Interface, Setting) and their sub-options.
      This one has just one sub-option per category.

      Example 2:  The Gameplay Genre Category has two sub-options related to it.



      Example Genre Table content:

       
      Just cracking the surface on One to One and One to Many relationships, I don't think this scenario is quite covered this way.

      Would each of those Genre Categories be portals showing only their related category ID?

      I presume that I would add fields to the Items::Table so I can pull related records:
      Items::Platform_IDfk
      Items::Genre_IDfk
      Items::Category_IDfk
      But those only support one relationship.
      Would I make value lists from those Genre Categories and Platforms and set them as tick box fields?
       
    • By Tony Diaz
      How do I set a field with a value list item from a script, from a set of tick box values? .. or remove a value list item, but leave whatever else is there alone?
      Looks like GetValue with the name of the value list and the position # of the value, but I'm sure that also means that if I change that value list, I need to change any scripts that reference them by position # too..
      Something like detecting if a string is already there, and if not add it, surrounded by C/Rs, unless it's the first item entry?
      For the first time a field is set, I presume I could just Set Field (field ; "Value List Item"), and if there's only one entry/line in it, just clear it.  But if there's already a value there, I just want to select an additional one.
    • By HOnza
      [FOR IMMEDIATE RELEASE]
      24U Software updates fmRESTor for FileMaker(R) Server 18
      The popular PHP connector for FileMaker Data API adds support for new features of FileMaker Server 18 and for easy deployment using Composer
       
      Prague, CZ -- August 1, 2019 -- 24U Software has released a new version of the popular open-source PHP library designed for PHP developers to easily integrate their code with the RESTful FileMaker Data API without having to learn the FileMaker Data API itself.
      The new version brings support for all new features added to the FileMaker Data API with the recent release of FileMaker Server 18, while maintaining full compatibility with the FileMaker Server 17 Data API as well.
      fmRESTor is now also available via Composer, a popular application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. Using Composer makes it even easier for PHP developers to maintain future compatibility of their code depending on fmRESTor.
       
      Features of fmRESTor:
      One object class conveniently handles everything Automatically generates authentication token Re-uses existing token to avoid unnecessary additional connections Automatically re-generates expired token Handles exceptions and provides meaningful error results Can handle raw form data for easier container uploads Provides customizable debug logging  
      Features added in the new version:
      Simple way to run a script and wait for its result with FileMaker Server 18 Methods for gathering information about FileMaker Server 18 and the accessed database Support for easily gathering value lists, i.e. for populating selects Added to Composer to make it easier for developers to maintain dependencies  
      Requirements
      fmRESTor requires PHP 5.6 or newer, including PHP 7, with support for cURL, and a FileMaker Server 17 or 18 to connect to.
       
      Availability and Pricing
      fmRESTor is available free of charge as open source, licensed under the "GNU LGPLv3" License. 24U greatly appreciates any feedback and contributions, but cannot provide free support for the tool. Developers may hire 24U to help them with their projects, either by purchasing paid support or by utilizing 24U's custom development services.
      More information: https://www.24usoftware.com/fmrestor
       
      About 24U Software
      With customers in 68 countries and 28 years of experience with the FileMaker platform, 24U excels in developing new or taking care of existing custom apps, optimizing their performance, identifying and resolving potential issues and liabilities, improving reliability, stability and scalability, integrating them with other systems including various hardware devices, and extending them beyond expectation.
      As a platinum member of the FileMaker Business Alliance, 24U helps global businesses around the world to maintain sustainable growth by working with their in-house developers or completely taking care of the maintenance and development of their business solutions.
       
      Customer contact:
      HOnza Koudelka
      Software Division Manager, 24U s.r.o.
      sales@24usoftware.com
      https://www.24usoftware.com
       
      Press Contact:
      pr@24uSoftware.com
      ###
       
      (c)2019 24U s.r.o. All rights reserved. 24U, 24U Software, and fmRESTor are trademarks of 24U s.r.o. FileMaker is a trademark of FileMaker, Inc., registered in the U.S. and other countries. All other trademarks are the property of their respective owners. Pricing and availability are subject to change without notice.
  • Who Viewed the Topic

    1 member has viewed this topic:
    arni 
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.