Good evening everyone,
forgive the beginner's question but I searched and didn't find what I need.
I have a form with a subform and I need that when I insert the form fields and save it, the subform first record is also saved and, if no values has been inserted in the subform record, i need to insert a default value in a lookup object and in a input object (number) of the subform.
Thanks for any tips
Costa
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Default value on subform objects when form is saved Topic is solved
-
- nuBuilder Team
- Posts: 4565
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 529 times
- Contact:
Re: Default value on subform objects when form is saved
Add a function nuBeforeSave() in your form's Custom Code.
Example:
Example:
Code: Select all
function nuBeforeSave() {
const subformId = 'mysubform'; // subform object id
const lookupObjectId = 'mylookup'; // Id of your lookup object
const lookupValue = '6505159c7272cf6'; // Primary key of lookup value to be set
const firstLookupObj = $('#' + subformId + '000' + lookupObjectId);
if (firstLookupObj.val() === '') {
firstLookupObj.val(lookupValue).addClass('nuEdited');
}
const numberObjectId = 'myinput'; // Id of your input/number object
const numberValue = '123'; // number value to be set
const firstNumberObj = $('#' + subformId + '000' + numberObjectId);
if (firstNumberObj.val() === '') {
firstNumberObj.nuSetValue(numberValue);
}
$('#' + subformId + '000' + 'nuDelete').nuSetValue(false);
return true;
}
Re: Default value on subform objects when form is saved
Thanks Kev1n,
always the top!
later i will try and i will be back to you
Costa
always the top!
later i will try and i will be back to you
Costa
Re: Default value on subform objects when form is saved
Perfect!
It works like a charm at the first shot.
Thanks Kev1n!!
Costa
It works like a charm at the first shot.
Thanks Kev1n!!
Costa