Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

I have this following situation in a FileMaker file:

1. User searches for and finds records in Table A.

2. User clicks a button in record row a1. This button is attached to script s1.

3. Script s1 has two branches:

a. If there is a related record in Table B, script goes to this related record.

b. If there is no related record in Table B, script creates a new related record, then goes to it.

4. User winds up in record b1 and layout b1 in Table B.

How can I code this behavior in PHP? I get error 101 - Record is missing.

I have this form snippet for page A.

I have this PHP snippet for page B.

$newPerformScript = & $fm->newPerformScriptCommand(myLayout, myScript, myParameter);

$result = $newPerformScript->execute();

ExitOnError($result);

I'm guessing I need to tell $newPerformScript to read the value of keyProjectID, but I'm not sure how/where to insert it.

TIA,

ken

Posted

Does it only fail when it's supposed to create a record? If so it's probably just getting the no related record error and exiting. It's also worth noting that as opposed to the Filemaker Client when the API runs a script it is not tied to a record just a layout so if you need the script to start out from a specific record you need to pass the id in the parameter and have the script use getScriptParameter() to grab the id then do a find.

However, I'd skip the Filemaker script all together and just put a portal containing B.id in the Table A layout the API calls. Then for each $record in A


$related = $record->getRelatedSet("relatedInB");



Unfortunately if there is no related set Filemaker throws an error with no code so rather than attempting to parse out the message string, which will change if you change the name of the related table reference you might as well check for the presence of a related set which is returned as an array of Filemaker_Record objects





if(is_array($related)){

  foreach($related as $relatedRec){

     ??>>">Show B Record<?

   }

}else{

      ??>>New B Record<?

}

then on link2tableBpage.php you can grab $_GET['Bid'] and either fetch the record or create a new one.

This topic is 5921 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
×
×
  • Create New...

Important Information

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