Retrieve ID of a saved database record

Retrieve the ID of a saved database record in ChronoForms.

Overview

The ID is stored within the save_data array after a database save action, but accessing it directly in a subsequent PHP action can be unclear.
Access the ID by referencing the specific save action's variable array. Use the correct array path to retrieve the value for use in your PHP code.

Answered
ChronoForms v7
wa walterbz 17 May, 2022
Hi all.
I made a simple form that saves data in a db. It works perfectly.
I need to call a php file with the ID of the corrisponding saved record ID: load.php?id=XX
Using the debugger I've seen that the ID (23) of the saved record is conatined in the "save_data_20" array :
Array
(
    [save_data_20] => Array
        (
            [result] => Data saved successfully!
            [dataset] => Array
                (
                    [option] => com_chronoforms7
                    [cont] => manager
                    [chronoform] => ControlloCF
                    [gpage] => end_page
                    [IMP_CdFis] => 00000123456
                    [IP_RicCdFis] => MRYWLM80A01H501H
                    [IP_RicDtSogg] => Mario Rossi
                    [IP_RicDataN] => 17/05/2022
                    [__cf_token] => 250ed622-a766-483d-a4b3-39f09ac7c520
                )

            [log] => Array
                (
                    [0] => INSERT INTO `pratiche` (`IMP_CdFis`, `IP_RicCdFis`, `IP_RicDtSogg`, `IP_RicDataN`)  values  ('00000123456', 'MRYWLM80A01H501H', 'Mario Rossi', '17/05/2022');
                )

            [var] => Array
                (
                    [IMP_CdFis] => 00000123456
                    [IP_RicCdFis] => MRYWLM80A01H501H
                    [IP_RicDtSogg] => Mario Rossi
                    [IP_RicDataN] => 17/05/2022
                    [id] => 23
                )

        )

    [php_27] => Array
        (
            [returned] => NULL
            [var] => NULL
        )

)
I tried several ways but I cannot rertieve the "id" value in order to use it in a php action.
Any suggestion?
Thanks
wa walterbz 17 May, 2022
Answer
SOLVED
in php I used this:

$this->_vars['save_data_20']['id']
gi gilliancowe 18 May, 2022
Hi,

Would you mind telling me how you saved the data in the DB with your form, I'm having trouble figuring it out.

Many thanks,

Gillian
This topic is locked and no more replies can be posted.