4 Replies Latest reply on Jan 4, 2016 8:57 AM by ElpicFayl

    Using scripts in button or in layout

    ElpicFayl

      Hello,

      I am asking myself a question about the best practice in using script in buttons or layouts.

      I am working on a form layout accessible via a button from another layout.

      When the user click on the button I have a script who cleans the global fields used in the form in order to present a clean slate each time the user access this form.

      So do I put my cleaning script in the button which access to this layout or do I use a script trigger with OnLayoutEnter?

      Thanks for your answers.

        • 1. Re: Using scripts in button or in layout
          jbrown

          HI. I'd say that your answer depends on your use case. Is a user on another layout every time before they access this layout, or will they see this layout on their screen and start using it when they have info to fill in.

           

          For a 'clean up' kind of script, I'd always put it at the END of the process. IF you have a "Submit" button, I'd put it there. Why not wipe out the data when you're finished with it?

           

          But you can always put it on the button that accesses this layout. If you have a script called "goToForm" that takes the user to this form, I'd run this clean up script at the very beginning. That way the user never sees old data in the form before its cleared out.

          • 2. Re: Using scripts in button or in layout
            ElpicFayl

            Hi,

            the user is always on another layout every time before they access this layout, but they have two buttons on the form a cancel and a submit form.

            So I can clean in my buttons scripts, or use the "goToForm" script.

            In fact in my case I think using the "GoToForm" script would be the best.

            Do you agree with it?

            • 3. Re: Using scripts in button or in layout
              jbrown

              It is reasonable to clean out the fields in the goToForm script. Make sure to do it before you actually go to that form layout. Since they're global fields, layout context is irrelevant. Clear them out. THen go to the layout. The user will be presented with a clean layout to add data.

               

              I would still probably clear out the fields AFTER the data has been entered and they click either "Cancel" or "Submit". I like the idea of cleaning up the fields when the process is done. It is sort of like variable scope: when you're done with a global field, clear it out.

               

              You could easily create another script that clears out the fields and then use the Perform Script [ ] script step inside your "cancel" or "submit" scripts. That's what I do.

              • 4. Re: Using scripts in button or in layout
                ElpicFayl

                Thanks for the info. Since I am a better safe than sorry kind of person I was cleaning every where I could. But I want to be sure it is not too time consuming for the process.