We have reset all users FileMaker related profile fields. Please take the opportunity to update your information,  this will provide background to members whom read your posts. Click here.

Jump to content
Jack Wright

Creating an array in PHP from a Value List in Filemaker

Recommended Posts

Jack Wright    0

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

Share this post


Link to post
Share on other sites
Mike Duncan    12

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?

Share this post


Link to post
Share on other sites
Jack Wright    0
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 
 

Share this post


Link to post
Share on other sites
dwdata    16
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!

Share this post


Link to post
Share on other sites
Jack Wright    0
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!

Share this post


Link to post
Share on other sites

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


  • Similar Content

    • By jamescv7
      XML error: No memory at line 1
      Greetings, this error occurred when the Filemaker API cannot generate a bunch of records. (1000+ records and above)
      I've adjusted the time out settings for PHP even the memory limits.
      Is there any possible solution for this?
       
      According to some information, the error turns out that the 10 MB XML scripts is unchangeable.
      thanks.
    • By crazybake
      I have a Value List "Quarter" with values:
      "Summer"
      "Fall"
      "Winter"
      "Spring"
      I planned to loop through these values and assign to a field using the various posts in the forum, but in testing the basic steps it's not working:
      Set Variable [$i; Value: 1]
      Set Variable [$quarters; Value: ValueListItems (Get (FileName); "Quarter")
      Set Variable [$count; ValueCount ($quarters)]
      New Record/Request
      Set Field [Program::ProgramQuarter; GetValue ($quarters; $i)]
      The field ProgramQuarter is not being set to any value....
    • By Ken d'Oronzio
      FREE fmREST.php – Simplifies & manages PHP connections to FileMaker 16’s REST-based Data API.
      The newly released FileMaker Server 16 now offers REST access to your FileMaker databases. There’s more about that how this impacts PHP developers here.
      The bottom line is that to use REST as part of your PHP solution, you would usually need to write a series of cURL functions and you would have to manually manage connecting & disconnecting from your server, and saving your tokens.
      This is a pain!
      We know it’s a pain, because we have spent the last several weeks rolling REST functionality into soSIMPLE Calendar.
      We created this class file to make it easier to manage dynamic REST sessions for soSIMPLE and our custom development. The goal of the class file was to help PHP developers start using the new REST engine as quickly and easily as possible.
      We’ll also be updating it with new features. If you’d like to add something to it, please let us know.
      What fmREST.php does:
      Makes every REST call available as a PHP function. Automatically login into FileMaker Server whenever you call any REST functions Saves your token for 15 minutes to reuse Checks for a broken or disconnected token and automatically reconnects and runs your function again Where do I get it?
      You can download the fmREST class file here.
    • By Joel Shapiro
      Hi all
       
      Come join us at the 11th annual CWP User Group at DevCon: Monday, July 24, 3:30–5:30pm  (before the 6pm opening keynote).
       
      Do you have something you might like to share with the group?  Please let me know.  We're always looking for new people! 
       
      Everyone's welcome.  Hope to see you there!
       
      -Joel
       
      http://jsfmp.com/cwp-user-group
      ~~~~~~~~~~~~~~~~~~~~~
      Joel Shapiro
      FileMaker Pro
      : database design
      : web development
      http://jsfmp.com
      415-269-5055
      ~~~~~~~~~~~~~~~~~~~~~
       
       
    • By bahizzlebrizzle
      Hey all,
      I have a table that has hundreds of records that describe archival footage based on "tape names" for a documentary I'm working on. I also have a second "in the cut" table that describes all of the clips contained in an edited episode that may have several iterations of the same tape, since we are using different sections of them.
      However, we want to DESCRIBE each iteration of the tape name contained in the "in the cut" table, differently.
      Instead of creating a field and manually typing out the description of each iteration in the "in the cut" table, is there a way to create an editable value list that connects to each tape name, allows the user to type in unique clip descriptions, but then stores it in its own list that can be accessed in the next iteration? This way when I go to a new iteration of a different tape name in the "in the cut" table, there would be a completely different list that is connected to that tape name.
      Thank you!
×