# Value of variable app in functions (purple blocks)

**URL:** https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194
**Category:** Questions about Thunkable X
**Created:** [May 2, 2023, 5:40pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194 "2023-05-02T17:40:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fedegarcia30hzc97a](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fedegarcia30hzc97a](https://community.thunkable.com/u/fedegarcia30hzc97a)
#### Post date: [May 2, 2023, 5:40pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/1 "2023-05-02T17:40:55Z")

</div>

Hi

I’ve builded a quite complex app with different external connectinos such as APIs and airtable and, in order to track the process im creating a log functionality.

The idea is to use a airtable table with different columns where ill write some information of different parts of the process. In this case a have 6 moments id like to track therefore ive create 6 columsn in my airtable and 6 app variables.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/9/f9255771d1a2651b53f2741f5bc1793cdd5f59b6.png)

When a button is pressed there are some functions i call which will execute get and/or set methods in airtable, so i setup the value of the corresponding app variable in case of error or success. Attached an example.

The function actulizanNumTarjetas will be called upon a button clicked after several other calls to similar functions (updating or retrieving airtable information). Is there is no error in the airtablemethods ill set the varaible with OK, if there is an error ill set yhe variable with the error.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/e/0e8a1f8af2e6fb9be09fd4ca345fee678fb54e6a.png)

At the end of the main event, i call a createRow method to insers all the different variables;

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/b/ab669414fbd0a26cf9c8b7909dfa1c4dd9abe0c0.png)

My issue is that not all the variables are populated in Airtable but the process has executed correctly

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/b/1b8a8b7ea0d68024ee4c4088830b53612fe11fa1.png)

Can it be due to sinchronization issues? Are the app variables behaving different when changing its value inside a function block?

Thanks!

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [May 2, 2023, 5:59pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/2 "2023-05-02T17:59:33Z")

</div>

The Create Row blocks takes time to create a row in an external data source such as Airtable. If it’s in a loop, make sure each loop iteration has time to complete that function block. You might try adding a Wait block after the Create Row block and test it with 0 seconds, 0.03 seconds, 0.1 seconds, etc. to see where the threshold is for delay.

That’s especially likely because you have a Navigate block _after_ the Create Row block. That’s going to fire immediately after the Create Row block fires, not after the Create Row block finishes. You need to move that navigate block into the “do” section of the Create Row block to ensure it happens _after_ the Create Row function completes. You might not even need a Wait block at all if you do that.

---

<div class="post-metadata">

### Author: ![fedegarcia30hzc97a](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fedegarcia30hzc97a](https://community.thunkable.com/u/fedegarcia30hzc97a)
#### Post date: [May 2, 2023, 6:13pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/3 "2023-05-02T18:13:18Z")

</div>

Thanks Tatiang

But still some other variables are correctly populated in the debug DB. Ill check adding some waits and moving the blocks into the “do” section to confirm everything has finished before writting the debug variables.

---

<div class="post-metadata">

### Author: ![fedegarcia30hzc97a](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fedegarcia30hzc97a](https://community.thunkable.com/u/fedegarcia30hzc97a)
#### Post date: [June 21, 2023, 9:04pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/4 "2023-06-21T21:04:05Z")

</div>

Hi

Ive updated my functions so that i ensure any setCell block will not continue untill its completed to keep the process synchronous. And as you can see in the screenshot, i set the debug app variables i initialize when opening the screen depending if there is and error or not

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/f/1f632fee971b4c342bbdad457ea82e57a0cc3b26.png)

Still when calling the crearLog function which will create a new row is not populating the right values

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5b2f9c6e99d026f0e3622707251c09fc85a664d8.png)

Screenshot of the airtable where some columns have the initiallited value instead of the one set inside the functions…

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/2/22619a517d0107176000c48ba8a9e00d12eafafc.png)

Any idea why this behaviour? Does the values set in app variable inside a function only remain inside that function?

---

<div class="post-metadata">

### Author: ![fedegarcia30hzc97a](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fedegarcia30hzc97a](https://community.thunkable.com/u/fedegarcia30hzc97a)
#### Post date: [July 11, 2023, 1:30pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/5 "2023-07-11T13:30:57Z")

</div>

Solved.

The issue is about timming, we know the airtable setCell works asynchrously and as i had no Wait timers (and my synchronous method is not working correctly) during the process, it was ending before the variables had their new value written.  
After i’ve added a Wait N seconds, everything is working correctly.

For this issue to not happend you need to confirm that any setCell function that is part of a secuential process is completely synchrnous.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [October 9, 2023, 1:31pm UTC](https://community.thunkable.com/t/value-of-variable-app-in-functions-purple-blocks/2400194/6 "2023-10-09T13:31:26Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
