# How to run script only once (at the loading of a given form) ?

**URL:** <https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089>\
**Category:** Q&A\
**Created:** [23 March 2020 07:01 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089 "2020-03-23T07:01:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabbe.kev\_1422207](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sabbe.kev\_1422207](https://community.ofelia.com/u/sabbe.kev_1422207)\
**Post date:** [23 March 2020 07:01 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089/1 "2020-03-23T07:01:13Z")

</div>

Hello,  
  
I have a form using Bonita and a script that load all the items from my database.  
  
I would like to be able to run a Javascript function that run only ONCE when the form is loaded from the user to get all my items and store it locally (temporary)  
  
Any suggestions will be highly appreciated.  
  
Best regards,

---

<div class="post-metadata">

**Author:** ![julien.mege](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/julien.mege/32/737_2.png) [@julien.mege](https://community.ofelia.com/u/julien.mege)\
**Post date:** [9 April 2020 06:41 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089/2 "2020-04-09T06:41:44Z")

</div>

Nice, so can you validate this answer,&nbsp;

- Use the JavaScript method "window.onload"&nbsp;to run script only once at the loading of a given form.

to make it more&nbsp;visible for&nbsp;community.

thx.

---

<div class="post-metadata">

**Author:** ![julien.mege](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/julien.mege/32/737_2.png) [@julien.mege](https://community.ofelia.com/u/julien.mege)\
**Post date:** [1 April 2020 15:56 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089/3 "2020-04-01T15:56:51Z")

</div>

hello, is it a UI-Designer form ?

in any case did you try to use "`window.onload`"?

---

<div class="post-metadata">

**Author:** ![sabbe.kev\_1422207](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sabbe.kev\_1422207](https://community.ofelia.com/u/sabbe.kev_1422207)\
**Post date:** [9 April 2020 02:53 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089/4 "2020-04-09T02:53:09Z")

</div>

Hello, yes and it did fix the issue :)

---

<div class="post-metadata">

**Author:** ![sabbe.kev\_1422207](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sabbe.kev\_1422207](https://community.ofelia.com/u/sabbe.kev_1422207)\
**Post date:** [9 April 2020 07:09 UTC](https://community.ofelia.com/t/how-to-run-script-only-once-at-the-loading-of-a-given-form/10089/5 "2020-04-09T07:09:22Z")

</div>

done thank you!

&nbsp;
