Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Save Parent record when adding to subform
Save Parent record when adding to subform
Hi All, When creating a new record and and then adding records to it in a subform, all the child records are lost if the parent is not saved first. What would be the best way to save the parent record before the operator enters a child record in a subform? MSAccess works this way by default.
-
- nuBuilder Team
- Posts: 4301
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Save Parent record when adding to subform
Hi,
This looks like a bug to me, I will look into it. In the meantime, add this JavaScript in the form's Custom Code field. This should fix the saving.
This looks like a bug to me, I will look into it. In the meantime, add this JavaScript in the form's Custom Code field. This should fix the saving.
Code: Select all
if (nuFormType() == 'edit') {
$('#' +nuSERVERRESPONSE.objects[0].id).addClass('nuEdited');
}
-
- nuBuilder Team
- Posts: 4301
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Save Parent record when adding to subform
If you're on v4.5. try the attached and updated nudata.php which should fix the issue.
You do not have the required permissions to view the files attached to this post.
Re: Save Parent record when adding to subform
Replaced with the new file and same results. I did reset the server and log back in.
-
- nuBuilder Team
- Posts: 4301
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Save Parent record when adding to subform
When I test it with this demo, it works just fine:
https://test.nubuilder.cloud/index.php? ... nuuserhome
Button: "Form + Subform"
Add a record, fill in the subform, save. Result: Both the records of the main form and subform are saved/created.
Do you do something different with your form?
https://test.nubuilder.cloud/index.php? ... nuuserhome
Button: "Form + Subform"
Add a record, fill in the subform, save. Result: Both the records of the main form and subform are saved/created.
Do you do something different with your form?
You do not have the required permissions to view the files attached to this post.
Re: Save Parent record when adding to subform
That's certainly a similar app to what mine needs to do. I just updated the entire system from github and still behaves the same on all subforms on my system. Is the code snippet on the demo app? If not any ideas what I maybe doing wrong?
-
- nuBuilder Team
- Posts: 4301
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Save Parent record when adding to subform
Yes, you can explore that demo.treed wrote:. Is the code snippet on the demo app?
I have no idea at the moment because I can't reproduce it and I have no idea what your form looks like, how you enter data etc...treed wrote: If not any ideas what I maybe doing wrong?
What would really help is a Minimal, Reproducible Example.
To test it, I modified the Access Levels form to allow blanks in the main form.
Then I added 1 row in a subform.
As you see, both records (main + subform) were saved in the table.
You do not have the required permissions to view the files attached to this post.
Re: Save Parent record when adding to subform
Found a difference. On my order table the primary key datatype is Int(11) with an auto increment. On the example I can't tell.
-
- Posts: 5
- Joined: Mon Jul 05, 2021 8:38 am
Re: Save Parent record when adding to subform
kev1n wrote:PK should be a varchar(25) and not AUTO_INCREMENT
https://forums.nubuilder.cloud/viewtopic.php?f=19
solve my problem it works