Hi Max,
Could you tell me how to get auto increment primary key from "save data" action? I need to use the new record's auto increment primary key for save as the second table data.
Regards,
Kittisak
Hi Kittisak
Use the {var:save_data_name.id} shortcode or use PHP:
$this->get("save_data_name.id")
the exact name and "id" field name depends on your save data and table, so check the form debug for that
Hi Max,
I had check debug but they do not have id data in save_data action.
Regards,
Kittisak
Don't forget to set in behaviors from the save the Primary Key on and the the name "id" from the table!
Paul
Hi Kittisak
As Paul has noted, you need to set the primary key in the Save Data behaviors, I forgot this step
Hi Max, I have some issue about primary key from save data action.Is it possible to use the new generated primary key from save data action in "Filename Provide" behaviors of upload file view.I try as the attached picture but It's not work.Best regards,Kittisak
Hi Kittisak
Yes you can, there is no image attached, but you can use {var:save_data_name.id} where "id" is the name of the primary key
Hi Max,
I can not attach picture in post.
Best regards,
Kittisak
yes, it looks like attachments have an issue, I will try to fix this soon
For your question, check the debug after the Save Data, what does it show ? did you set the primary key in the Save Data settings ?
Hi Max, On the debug after saved data, they show id (primary key) in save data action array correctly but not show in the file name provider.Regard,Kitiisak
Please try to take a screenshot of that and either paste it in the reply box directly or upload it using the image icon in the reply editor, that would work until I fix the attachment button
I need a screenshot of the primary key in the debug and of your file provider settings

Hi Max,This is save data action in submit

This is upload file and file name provider

In debug, it show id properly
but not set in the file name
regards,kittisak
Hi Kittisak
The file upload happens when the form page is submitted and before the Save Data runs, if you need to use the new record id then I think that you will need to have either a 2 pages form and have your file field at 2nd page after the Save Data has provided the ID OR you can keep everything as it's but use PHP to rename the file after it has been created.
Hi Max,
Can I put PHP action to rename the file after save data action?
Regards,
Kittisak
yes, before or after the save does not matter
