Page 1 of 1

RecordId For Subform Rows

Posted: Sun Jul 31, 2011 11:24 am
by hunt342
When a subform is saved I want to update a couple fields [that are not in the subform] for that record row in the DB. To do this I need the primary key for that subform row. I've added the code in the "After Save" Section Of the "Edit Code" for that form. To get the primary I'm querying the database.

I was wondering if there was a better way to get the primary key of the subform row in the "After Save".

Like we do for the forms using Hash Variable / $_POST [#recordID# / $recordID]

Re: RecordId For Subform Rows

Posted: Mon Aug 01, 2011 4:58 am
by admin
hunt342,

This is the main place you can't use hash variables.

The simple reason is that hash variable values are inserted into the PHP code just before it is run (making them static)

Here's a bit of code that prints out results to the table zzsys_trap (I created it from he invoice form in the sampledebtors screen)...

Code: Select all

$subformname     = "FMinvoice_item";
$rows            = $_POST["rows" . $subformname];

nuDebug($rows);  

for($i = 0 ; $i < $rows ; $i ++){

     $fieldname  = 'FMinvoice_item' . substr('000'.$i, -4)  . 'tri_amount'; 

     nuDebug($fieldname . ' ' . $_POST[$fieldname]);  
}

I hope this helps..

Steven