JavaScript to set field value on fields in different sections
I would like to have a button at the bottom of my form that sets the values on several fields when clicked and then submits the form. I'm using the JavaScript below and it works to set the first field that is in the same section as the button but is not setting the second field that is on the second section of the form.
function BSATriageApp(){
document.getElementById("EPSCGate").value = "Working";
document.getElementById("BSATriageResults").value = "Not Working";}
Additionally I would like to have some of the field values result in the Current Users Full Name and the Current Date. I also need the JavaScript to Submit the form after executing the above activate. Thanks in advance for your help.
-
hi Darci,
Please take a look at this documentation link, it should achieve what you are after.
https://documentation.agilepoint.com/00/appbuilder/cloudjsSetFieldValue.html
Lucas
-
I tried using:
var options = {};
options.fieldId = 'TextBox1'; // individual control
options.value = 'Hello World';Inside my function but it didn't seem to work. Do you have to call out the section in order to set the field values of the fields in different sections?
What I have above is working just not on the different sections on the form.
-
Hi Darci,
It looks like there are some pieces missing to your JS.
Please add:
eFormHelper.setFieldValue(options, function (result) //helper method to set the form field value in eForms
{
if (result.isSuccess) //check if is success
{
console.log(result.data); //logs the data holds empty object
}
else
{
console.log(result.error); //logs the error
}
});
If this doesn't work, please raise a support ticket and we will ensure the right resources assist you.
Lucas
-
That worked using the code below.
function BSATriageApp(){
document.getElementById("EPSCGate").value = "3 - Sizing Analysis Review"; //first partvar options = {}; //second part
options.fieldId = 'BSATriageApprover'; // individual control
options.value = 'Proceed';eFormHelper.setFieldValue(options, function (result)
{
if (result.isSuccess) //check if is success
{
console.log(result.data); //logs the data holds empty object
}
else
{
console.log(result.error); //logs the error
}
});}I'm using a button to execute the code and the first line works for the fields that are on the same page/section of the form as the button and the second part of the code works for fields that are on a different page/section of the form from the button.
The first one seems much cleaner and simpler, any idea why that same line of code doesn't work for different sections of the form?
Please sign in to leave a comment.
Comments
5 comments