Forums

[SOLVED] Get value for autonumber field after form is saved

momentis 04 Dec, 2012
I have a form that I need to execute some code after the form is saved to a table. When the form is saved, an autonumber field (regmain_id) is generated. I need to use the value of 'regmain_id' in some code that will add rows to another table. Is there any way I can access the value of 'regmain_id' in PHP script that runs after the form is saved?
momentis 04 Dec, 2012
When I place a Debug action between the DB Save and Custom Code actions in the On Save event, I can see the following:

    [chronoform_data] => Array
        (
            ...
            [regmain_id] => 26
            ...
        )

    [chronoform_data_regmain_id] => 26


That's the value I need, but I cannot figure out how to access it in the next step.

Rick
momentis 05 Dec, 2012
Figured this out. When I was calling the field in some PHP, I was using:

$regid = $form->data['regmain_id'];

When I needed to call:

$regid = $form->data['chronoform_data']['regmain_id'];

Now it works!
GreyHead 07 Dec, 2012
Hi Rick,

Well done; sorry I didn't get to look at it sooner.

Bob
momentis 07 Dec, 2012
Bob,

Not a problem! Maybe I shouldn't pack these forums with my silly problems - only to solve them later!!

Happy Holidays!
Rick
This topic is locked and no more replies can be posted.