# Bug? Can't store correct access\_code immediately after creation

**URL:** <https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454>\
**Category:** Database\
**Created:** [February 12, 2017, 6:50pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454 "2017-02-12T18:50:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1984labrat](https://avatars.discourse-cdn.com/v4/letter/1/edb3f5/32.png) [@1984labrat](https://forum.bubble.io/u/1984labrat)\
**Post date:** [February 12, 2017, 6:50pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/1 "2017-02-12T18:50:38Z")

</div>

I want a user to be able to create data that can be viewed by anyone to whom he/she gives the access\_code. Therefore, on signup workflow (using standard Bubble Signup form), I create an access\_code for the new user (using the Calculate RandomString function) and store it in the access\_code field of the User table. (I added the access\_code field to the User table.)

I have a separate table for the (semi-public) data. Therefore, in a second action for the SignUp event, I (try to) store in the access\_code field of the data table the newly created access\_code (which should now be the “current user’s access\_code” created in the preceding action). I do this by storing the “current user’s access\_code” in the access\_code field of the data table.

BUT, Bubble stores **two different access codes** in the two tables (viz., the User table and the data table). I only call the “Calculate RandomString” function one time (in the first of the two work flow actions), so I cannot understand how two different codes are being generated. I modify the User table with “access\_code = Calculate RandomString” in the first action, and I (try to) modify the data table with “access\_code = Current User’s access\_code” in the second action. That does not work and I get two different codes in the two tables.

The only way I was able to prevent this was to wait until I navigated off of the page before executing the second action. Then on the page load event of the next page, I stored the current user’s access\_code in the data\_table. That works.

This is just plain weird and I suspect that it is a bug.

---

<div class="post-metadata">

**Author:** ![pnodseth](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/pnodseth/32/2611_2.png) [@pnodseth](https://forum.bubble.io/u/pnodseth)\
**Post date:** [February 12, 2017, 6:54pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/2 "2017-02-12T18:54:42Z")

</div>

Its really weird and I’ve had the same issue when generating SMS verification codes. If I store the code on the user and then send the generated code (stored on the user) to an SMS provider, it sends a different code.

---

<div class="post-metadata">

**Author:** ![dmurthy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dmurthy/32/6312_2.png) [@dmurthy](https://forum.bubble.io/u/dmurthy)\
**Post date:** [February 12, 2017, 7:02pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/3 "2017-02-12T19:02:20Z")

</div>

I use the random string to create transactions IDs.

What I do is store the random string in a DB table with name transaction\_id and then access that using current user’s transaction\_id last item.  
It works for me.

---

<div class="post-metadata">

**Author:** ![petter](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/petter/32/98626_2.png) [@petter](https://forum.bubble.io/u/petter)\
**Post date:** [February 14, 2017, 5:41am UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/4 "2017-02-14T05:41:18Z")

</div>

I’m experiencing the same thing. I tried to get around by generating the random string in a workflow and store it in a state (two strings are generated), and then trigger a custom event copying the content from the first state to a second. It did not work.

Workflow 1  
Set state STRING TEMP generate random string (two strings are generated)  
Trigger Custom workflow

Custom workflow  
Set state STRING, value from STRING TEMP (a third string is generated)  
Email string to user (the third string is mailed)

I prefer to not use the database for this, so I’ll keep the page on ice until we know if is indeed a bug or not. Thanks for the workaround anyway @dmurthy.

---

<div class="post-metadata">

**Author:** ![natedogg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/natedogg/32/79328_2.png) [@natedogg](https://forum.bubble.io/u/natedogg)\
**Post date:** [February 14, 2017, 6:28am UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/5 "2017-02-14T06:28:52Z")

</div>

Just chiming in here: I’ve also experienced having two different random strings generated after calling Calculate RandomString once. The random codes that were sent to my users were different than what was being stored.

I ended up just using Blockspring.

---

<div class="post-metadata">

**Author:** ![mishav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mishav/32/6420_2.png) [@mishav](https://forum.bubble.io/u/mishav)\
**Post date:** [February 14, 2017, 6:34am UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/6 "2017-02-14T06:34:15Z")

</div>

What I think is happening is that the random number is being generated on both the client and the server, with different results.

@josh, could you please explain what is happening, and why some workarounds are effective and others aren’t?

---

<div class="post-metadata">

**Author:** ![emmanuel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/emmanuel/32/27657_2.png) [@emmanuel](https://forum.bubble.io/u/emmanuel)\
**Post date:** [February 14, 2017, 2:04pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/7 "2017-02-14T14:04:11Z")

</div>

@mishav can you create a simple case that shows the random numbers aren’t the same? It shouldn’t be the case but there may be a bug there.

---

<div class="post-metadata">

**Author:** ![mishav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mishav/32/6420_2.png) [@mishav](https://forum.bubble.io/u/mishav)\
**Post date:** [February 15, 2017, 3:41am UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/8 "2017-02-15T03:41:28Z")

</div>

Hi @emmanuel,

Here is an example, showing @1984labrat’s problem:

_(Links removed)_

Screen capture:  
 ![](https://us1.discourse-cdn.com/bubble/original/2X/3/3cb330980fc52fd4b2e592fe2a16ff3c5a8ad3b4.gif)

---

<div class="post-metadata">

**Author:** ![emmanuel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/emmanuel/32/27657_2.png) [@emmanuel](https://forum.bubble.io/u/emmanuel)\
**Post date:** [February 15, 2017, 10:00pm UTC](https://forum.bubble.io/t/bug-cant-store-correct-access-code-immediately-after-creation/10454/9 "2017-02-15T22:00:01Z")

</div>

This is fixed
