# How to access properties on initialize?

**URL:** <https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969>\
**Category:** Plugin builders\
**Created:** [April 22, 2023, 9:13am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969 "2023-04-22T09:13:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexcooney5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/alexcooney5/32/206227_2.png) [@alexcooney5](https://forum.bubble.io/u/alexcooney5)\
**Post date:** [April 22, 2023, 9:13am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/1 "2023-04-22T09:13:13Z")

</div>

I’m sure this is a basic question for more experienced plugin dev, but I’m a bit stumped.

I have a field called “Time Delay”. I essentially want users to be able to set the time before a popup appears on screen.

 ![Screenshot 2023-04-22 at 10.11.27](https://us1.discourse-cdn.com/bubble/original/3X/8/e/8ef31eb44409bf068e0d6e3d88277c157f50756c.jpeg)

The obvious thing I tried was to set a variable in the “initialize” function that accessed the field I created.

 ![Screenshot 2023-04-22 at 10.12.39](https://us1.discourse-cdn.com/bubble/original/3X/b/1/b1467696c8006d6992a209b5d80ce1f74a3ef9fc.png)

But this is not possible. You cannot access properties in the initialize function.

How can you initially set a variable based on a field the user can set a custom value for?

---

<div class="post-metadata">

**Author:** ![rico.trevisan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/rico.trevisan/32/170176_2.png) [@rico.trevisan](https://forum.bubble.io/u/rico.trevisan)\
**Post date:** [April 22, 2023, 9:16am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/2 "2023-04-22T09:16:39Z")

</div>

Unfortunately you can’t access properties on initialize.

What I do is – on the update function – I create a do once if to mimic the initialize function.

---

<div class="post-metadata">

**Author:** ![alexcooney5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/alexcooney5/32/206227_2.png) [@alexcooney5](https://forum.bubble.io/u/alexcooney5)\
**Post date:** [April 22, 2023, 9:45am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/3 "2023-04-22T09:45:47Z")

</div>

Thanks @rico.trevisan!

Am I correct in saying that’s what you’re doing in your [Code Syntax Highlighter plugin](https://bubble.io/plugin/%F0%9F%A4%8C-code-syntax-highlighter-1680072712220x425578562619179000)?

---

<div class="post-metadata">

**Author:** ![vladimir.pak](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/vladimir.pak/32/135208_2.png) [@vladimir.pak](https://forum.bubble.io/u/vladimir.pak)\
**Post date:** [April 22, 2023, 9:47am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/4 "2023-04-22T09:47:06Z")

</div>

You can reate it in `initialize` with `display:none` and show up in `update`.

---

<div class="post-metadata">

**Author:** ![alexcooney5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/alexcooney5/32/206227_2.png) [@alexcooney5](https://forum.bubble.io/u/alexcooney5)\
**Post date:** [April 22, 2023, 10:07am UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/5 "2023-04-22T10:07:07Z")

</div>

thanks @vladimir.pak ! Do you have any open-source plugins where you do this?

I had a look through the code for your [Splash Screen plugin](https://bubble.io/plugin/splash-screen-1650570954859x699122771572293600) but couldn’t quite figure out where you’re applying the principle

---

<div class="post-metadata">

**Author:** ![vladimir.pak](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/vladimir.pak/32/135208_2.png) [@vladimir.pak](https://forum.bubble.io/u/vladimir.pak)\
**Post date:** [April 22, 2023, 4:44pm UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/6 "2023-04-22T16:44:16Z")

</div>

Nope, I don’t have one. lf you’d describe in more details what you’re trying to achieve, maybe I could say something more specific for you case.

---

<div class="post-metadata">

**Author:** ![pork1977gm](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/pork1977gm/32/245627_2.png) [@pork1977gm](https://forum.bubble.io/u/pork1977gm)\
**Post date:** [April 23, 2023, 8:48pm UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/7 "2023-04-23T20:48:46Z")

</div>

If it helps, you should be able to set a global variable inside Update, then reference it inside Initialize.

Instance.data.time\_delay = properties.time\_delay;

Other than that, try and define all property values inside update, and remember when something changes, then that Update block will rerun.

If you do need to take action on it only once and you decide to put it inside Update, then do as Rico suggested and wrap into something like this…

If (!instance.data.hasRun) {  
// do what you need here  
instance.data.hasRun = true;  
}

---

<div class="post-metadata">

**Author:** ![chris.williamson1996](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/chris.williamson1996/32/70581_2.png) [@chris.williamson1996](https://forum.bubble.io/u/chris.williamson1996)\
**Post date:** [April 23, 2023, 8:58pm UTC](https://forum.bubble.io/t/how-to-access-properties-on-initialize/258969/8 "2023-04-23T20:58:09Z")

</div>

You don’t exactly need a plug-in for this. You can do it with the “do every 5 seconds” set seconds to however many you want. Run only once.

Plug-in would make it a bit easier though.
