# If Variable Defined action

**URL:** https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186
**Category:** Discussion
**Created:** [April 23, 2009, 10:18am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186 "2009-04-23T10:18:51Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 23, 2009, 10:18am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/1 "2009-04-23T10:18:51Z")

</div>

Is it possible to get the "If Variable Defined" action to only execute child actions if a variable is defined AND (here's the new part) it also equals some value.

-Matt

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [April 24, 2009, 12:23pm UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/2 "2009-04-24T12:23:47Z")

</div>

Hi Matt,   
  
 You can’t do both checks in the ‘If Variable Defined’ action, you’ll need to use a separate ‘If…Then’ action to perform the comparison.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 24, 2009, 6:41am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/3 "2009-04-24T06:41:44Z")

</div>

Ok, thanks. &nbsp;So then my next question is how do I use a dyanmic variable in an IF action.

I have a variable like %VariableName%, and I want to check if it's value equals something

In the "If variable defined" action it expands %VariableNmae% to the actaul variable, but I'm not sure how to do that in the IF action.

-Matt

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [April 28, 2009, 12:57pm UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/4 "2009-04-28T12:57:14Z")

</div>

Hi Matt,   
  
 To compare the value of the variable in the If…Then action you simply specify the variable surrounded by ‘%’. For example:   
  
 Left-Hand Value: %VariableName%   
 Right-Hand Value: ValueToBeCompared   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 28, 2009, 5:52am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/5 "2009-04-28T05:52:18Z")

</div>

I don't think I explained it well enough.

Let's say I have&nbsp;3 variables defined.&nbsp; DeployApp1,&nbsp; DeployApp2, BuildingApp

DeployApp1& 2 are boolean and control if an application needs to be deployed.&nbsp; BuildingApp is a paramater that's passed in to tell us what is currently building.&nbsp;It's&nbsp;value will be App1 or App2.

I want to dynamically update the variable name used in the If statment based off which app was passed in thru the BuildingApp variable.&nbsp; So the Left-Hand side is something like Deploy%BuildingApp% and the Right-Hand side is True.&nbsp;

Problem is the If statement always fails because it ends up checking something like DeployApp1 = True.&nbsp; When I really wanted DeployApp1's value on the Left-Hand side.

So I think that's a better example.&nbsp; Is this possible?&nbsp; Maybe I should just try something like %Deploy%BuildingApp%%

-Matt

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [April 29, 2009, 6:28am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/6 "2009-04-29T06:28:12Z")

</div>

Hi Matt   
  
 What you are trying to do will not work due to how variables are parsed and expanded.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 29, 2009, 8:35am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/7 "2009-04-29T08:35:59Z")

</div>

Let me step back and explain what I'm trying to do. Maybe their's a much better way to do it.

In FB Server I have a project that builds a Visual Studio 2008 solution with multiple executables in it. I want the FB Server project to have a checkbox for each executable in the solution. So it looks like this.

We only want the projects that are checked to be deployed when the project runs.

It would be easy to use hardcoded variables in the FB Project and just create a If action to check each one, but as this list will continaully grow I'd like to figure out how to do it dynamically.

So in the FB project I'm trying something like this.

I have a folder iterator which loops thru all of the executables in the solution. The folder names match the variable names, so we actually have a folders named AWSApplicationPersistance, EHealthApplicationMapping, and ThirdParty. So what I want to do is add an&nbsp;IF Action that uses the current folder's name from the folder iterator as a pointer to the checkbox variable to see if we should deploy that folder. So basically in the If statement I have a variable called CurrentFolder who's value is actually the name of another variable that is either ture or false, it's those checkboxes.

![001_FB.jpg](https://www.finalbuilder.com/forums/uploads/default/original/1X/3d7f981ce1bb3ad6c963e46d97b40f1ec13ac1ef.jpeg)

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [April 30, 2009, 2:23am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/8 "2009-04-30T02:23:40Z")

</div>

Hi Matt,

I've attached an example project which should do what you're trying to achieve (I hope).

Regards,  
Paul.

[VariableExample.fbz6](https://www.finalbuilder.com/forums/uploads/default/original/2X/c/cb6316878e617f8095144c302c046125a95ed177.fbz6) (2.378 KB)

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 30, 2009, 12:58pm UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/9 "2009-04-30T12:58:11Z")

</div>

And here is my example for creating a Dynamical List, Just change the Iterator to Folder Iterator.

Daphna Levin

[TestDynamicList.fbz6](https://www.finalbuilder.com/forums/uploads/default/original/2X/8/80035bfa8d1597382a042e1ddca8d43e58b7470f.fbz6) (2.777 KB)

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 30, 2009, 4:10am UTC](https://www.finalbuilder.com/forums/t/if-variable-defined-action/1186/10 "2009-04-30T04:10:47Z")

</div>

Thanks Paul,

That's was exactly what I was looking for.

-Matt
