I am working on recreating a form that was created in the Classic Designer and I'm moving it to the Modern Designer.
What I need to do is based on the current user task step, I need to populate a field (FieldID 8) with a value. So if the step name contains "Approval Level 1" then I need it to insert a 1 into Field 8. Here is the JavaScript that I created for it, but it does not populate the field when I preview it and change the step in the top right. I wasn't sure if there is something wrong with my JavaScript or if it is because the preview doesn't reload the form when the value is changed.
LFForm.onFormLoad(function () { var stepName = LFForm.getStepName(); if (stepName.includes("Approval Level 1")) { LFForm.setFieldValues({ fieldId: 8 }, "1"); } else if (stepName.includes("Approval Level 2")) { LFForm.setFieldValues({ fieldId: 8 }, "2"); } else if (stepName.includes("Approval Level 3")) { LFForm.setFieldValues({ fieldId: 8 }, "3"); } else if (stepName.includes("Approval Level 4")) { LFForm.setFieldValues({ fieldId: 8 }, "4"); } });
Using Forms 11.0.2311.50564