I’m working with the new Form component in Perspective to create a calculation form for our manufacturing team. Based on the values entered by the user, the system will calculate how much of each material needs to be added. The form will then be used to generate new work orders in our system.
I’d like to provide a preview of the calculations on the right-hand side before the user presses submit, so they can verify the results before submission. However, I’m not sure how to capture the values from the form to generate this preview before the submit button is pressed.
I’m sure I’m just missing something, so any guidance would be greatly appreciated!
Hi @Tburgess, the following will you get you started:
In the Property Tree, under actions → submit set fireComponentEvent to true and fireSubmissionEvent to false. Configure a Script onSubmitActionPerformed Component Event for the your Form. Here you can script your preview as the form data is provided (event). You can perform a final form submission here as well by calling:
self.submit(options = { "fireComponentEvent": False, "fireSubmissionEvent": True, "submissionHandler": "replace with name of your handler" })
It seems that this still requires the user to press the submit button, correct? I was hoping to start showing the calculations immediately, before the user has to press any buttons.
The calculations I’m referring to involve about 20 parameters that need to be computed using our formula. If users have to click a button each time to see results, they might get frustrated pretty quickly.
I saw that the onChange script could work for what I want to do, but it seems like I’d need to write a ton of if statements to check which key was changed. What I was hoping to do instead was something like this:
Whenever a change happens to one of the values, run a script that updates my page properties based on the current form values — for example: