# How to create a dynamic if-else statment

**URL:** <https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508>\
**Category:** Ask for Help\
**Created:** [June 15, 2025, 2:13pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508 "2025-06-15T14:13:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maazsaeed](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maazsaeed/32/90243_2.png) [@Maazsaeed](https://community.glideapps.com/u/Maazsaeed)\
**Post date:** [June 15, 2025, 2:13pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/1 "2025-06-15T14:13:07Z")

</div>

I have two columns

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/4/746be9666ef8b868a999ee43b0b87a5062e87b34.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/c/5cecac2a719adbf126a6147175219d80c5589cfc.png)  
One is Template Keywords, and other is Template IDs  
Template IDs include the type we need to display when we detect the keyword inside the given data  
So, for example we can detect if the template is template 1 if Account number(BBAN) is present in it and similarly template 2 if Instrument ID is present in it.

I have the logic but I don’t know how to do it

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [June 15, 2025, 2:43pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/2 "2025-06-15T14:43:35Z")

</div>

Not totally sure what the goal is, but a good rule of thumb is to check all the false conditions first, and then handle the true case. Sometimes nesting `if else` blocks may help get what you want.

---

<div class="post-metadata">

**Author:** ![Maazsaeed](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maazsaeed/32/90243_2.png) [@Maazsaeed](https://community.glideapps.com/u/Maazsaeed)\
**Post date:** [June 15, 2025, 2:52pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/3 "2025-06-15T14:52:33Z")

</div>

Can you tell me how can I get desired output?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [June 15, 2025, 3:16pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/4 "2025-06-15T15:16:16Z")

</div>

So you want the value of ‘Template 1’ returned from the ID array if something finds ‘Account Number’ in the Keyword array, because they are both in position 1 in both arrays? How are you determining that something is found in the Keyword array? Are the array items always in a consistent order? Where are the Lookups coming from? I think we need a lot more information to determine what you need. It seems to me that something is being made more complicated than it needs to be.

---

<div class="post-metadata">

**Author:** ![Maazsaeed](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maazsaeed/32/90243_2.png) [@Maazsaeed](https://community.glideapps.com/u/Maazsaeed)\
**Post date:** [June 15, 2025, 3:27pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/5 "2025-06-15T15:27:19Z")

</div>

I have a Templates table that includes all the information related to each specific template. I’m using a lookup to fetch the entire template. Then, I extract all of its IDs and the specific keywords associated with it.

Each template has unique keywords — for example, a keyword in Template 1 won’t appear in Template 2 or 3. What I want to do is create a conditional statement. For instance, if the detected template is Template 1 and it includes the keyword “Account Number”, then a specific action should be triggered.

So, I’m trying to figure out the best approach to implement this logic. What would be the most effective way to handle this

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [June 15, 2025, 4:15pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/6 "2025-06-15T16:15:57Z")

</div>

I think that just confused me more. I’m not understanding the entire flow and what the data looks like.

---

<div class="post-metadata">

**Author:** ![Maazsaeed](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maazsaeed/32/90243_2.png) [@Maazsaeed](https://community.glideapps.com/u/Maazsaeed)\
**Post date:** [June 15, 2025, 5:12pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/7 "2025-06-15T17:12:03Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/9/b90e0844ece5fafc4ff6f319e002912b36e693c5.png)  
This is how the templates table looks like

---

<div class="post-metadata">

**Author:** ![Maazsaeed](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/maazsaeed/32/90243_2.png) [@Maazsaeed](https://community.glideapps.com/u/Maazsaeed)\
**Post date:** [June 15, 2025, 5:17pm UTC](https://community.glideapps.com/t/how-to-create-a-dynamic-if-else-statment/82508/8 "2025-06-15T17:17:03Z")

</div>

Thanks for the help guys, I have got it working using a json Object and then using javascript
