Question
Is it possible to pass data from the DOM of a website, where a quick form is embedded via the script
tag, into one of its fields during loading?
For example, a form is embedded on a site and is only available to authorized users. The DOM
contains the user_name
of the currently logged-in user, and there is a desire to pass it into the form.
Answer
When configuring the form, you can set the viewtype
parameter to js
for the data type field.
The field must be accessible for the role from which the form is called, otherwise it will not be displayed in the DOM.
For the user, this field is visually hidden.
In the form settings, set your id in the id
parameter, which can be used to access this field in the DOM.
To pass data to it, specify this in the site's page JS:
<script>
let interv = setInterval(()=>{
let element = document.getElementById('your_id_for_field');
if(element && element.setTotumValue){
clearInterval(interv)
element.setTotumValue(JSON.stringify(
["your_data"]));
}
}, 100);
</script>