AnsweredAssumed Answered

PHP getValueListTwoFields with a record ID

Question asked by rhowe on Oct 30, 2012
Latest reply on Nov 1, 2012 by rhowe

A question similar to this was asked about a year and a half ago by someone else, but there were no responses. Since I have come across the same problem, I'm asking it again:

 

Setup: My database has a dynamic value lists -- it changes based on values in a record's field. It works fine in FMP; going record to record the value list changes appropriately.

 

In PHP, I'm using getValueListTwoFields ('my-value-list-name-here', $my-record-ID). As in the long-ago post, I echo back the record ID to verify that it's correct. Nevertheless, the value list that I get back is the one from the first record.

 

I've checked the web user privilege set, even going to far as to give the web user full access, without success. I'm at a dead end on what to look for next.

 

****

Here's the relevant PHP code, with comments on what I'm doing:

 

// I'm creating an audit-trail style record to track edits. In the New_Edits layout, passing a participant-id will populate all the relevant fields (via auto-enter relationships) from the main record. The database properly fills out all the fields.

$rec = $fm->createRecord ('New_Edits');

$rec->setField ('Participant_ID', $clean['Participant_ID']);

$result = $rec->commit();

ExitOnError($result);

 

// so, at this point, we have a populated record. Here I get the record ID and echo it back to the web page, and it does indeed match the record ID I display on the layout.

 

$rec_ID = $rec->getRecordId();

echo "Rec ID = " . $rec_ID . "<br />";

 

// So: for this record, the participant is in a particular program. The program operates in several districts. My value list presents the districts for a program, and naturally the value list differs based on what the program is.

// I build the value list by getting the layout object, and passing the value list and the record ID to getvaluelisttwofields:

 

$layout = $fm->getLayout('New_Edits');

$District_Options = $layout->getValueListTwoFields('all_dists_for_program',$rec_ID);

 

// I build the district value list as a popup menu...where I put the district ID (number) into field 'district_ID_TMP' while displaying the district name to the web user

 

$district_value_list = "<select name='district_ID_TMP'>";

foreach($District_Options as $district_name=>$district_ID)

{

$district_value_list .= '<option value="' . $district_ID . '">' . $district_name . '</option>';

}

$district_value_list .= '<select>';

 

 

******

In spite of passing the record ID, I always get the value list that pertains to the first record.

 

Suggestions on where I should look next?

Outcomes