Page 1 of 1
Beginners question: How to define a default value to a hidden textvalue?
Posted: Fri Jun 20, 2025 7:24 pm
by Espo
Hi
I'm trying to create a subform which sends some data to the database.
each row should contain a hidden field which contains the nuhash USER_TEAM Value.
How am I able to set the Input field hidden so that the rows contain automatically the value?
I thoud there is a input field class "hash_variable". (just a succesition)
If I'm on the wrong way, - how do I send hash_coockie values combined with the other fields to the database ?
Kind regards,
Michael
Re: Beginners question: How to define a default value to a hidden textvalue?
Posted: Sun Jun 22, 2025 7:45 am
by kev1n
Hi Michael,
To populate a specific field in the subform with the user's team, use the JavaScript function nuUserTeam()
in combination with the nuSetValue() function.
Let me know if you need an example.
Re: Beginners question: How to define a default value to a hidden textvalue?
Posted: Mon Jun 23, 2025 8:51 am
by Espo
Yes, that way I tryed it and it works in a normal form, but how can I use it in subform?
There I only found the way of custom code of this field (onclick, or so) bit it didn't work until now.
I tried a Input field (Text) and custom code: nuSetValue('tra_mandant', nuUserTeam());
But then nothing happens.
Re: Beginners question: How to define a default value to a hidden textvalue?
Posted: Mon Jun 23, 2025 10:27 pm
by kev1n
Every subform field is composed of three parts:
1.
Subform Object ID – e.g.,
mysubformId
2.
Row number – a three-digit, zero-padded index (e.g.,
000
)
3.
Object (field) Id – e.g.,
tra_mandant
Combined, a full field ID might look like:
mysubformId000tra_mandant
To populate a field in the current subform row, add an
afterinsertrow event to the subform and call
within it.
Declare this function in the form's Custom Code field
Code: Select all
function subformAddUserTeam(event){
// retrieve the subform Object ID
const sfId = event.currentTarget.getAttribute('data-nu-prefix').slice(0, -3);
// ID of the object whose value needs to be set (change this if targeting a different field))
const objectId = "tra_mandant";
// Value to assign (current user's team)
const value = nuUserTeam();
// Get the current subform row index
rowIndex = nuCurrentRow();
// Construct the full object ID for the target field
const objId = `${sfId}${nuPad3(rowIndex)}${objectId}`;
// Set the field value
nuSetValue(objId, value);
}