# Custom Action - Retrieve field whose value is a variable

**URL:** https://www.finalbuilder.com/forums/t/custom-action-retrieve-field-whose-value-is-a-variable/1505
**Category:** Discussion
**Created:** [June 18, 2010, 3:19am UTC](https://www.finalbuilder.com/forums/t/custom-action-retrieve-field-whose-value-is-a-variable/1505 "2010-06-18T03:19:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![robm](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/r/278dde/32.png) [@robm](https://www.finalbuilder.com/forums/u/robm)
#### Post date: [June 18, 2010, 3:19am UTC](https://www.finalbuilder.com/forums/t/custom-action-retrieve-field-whose-value-is-a-variable/1505/1 "2010-06-18T03:19:54Z")

</div>

Hi -

&nbsp;&nbsp; **BACKGROUND**

&nbsp;&nbsp;We are using FB 5 Professional.

&nbsp;&nbsp;I have a custom action that has a few fields. &nbsp; The fields can be set to a variable.

&nbsp;&nbsp; In my C# class which implements the custom action how can I tell if a field is set to a variable?&nbsp;

&nbsp;&nbsp;For example, in my OnExecute() method I have the following code....

&nbsp;&nbsp;string sSourceFolder = Context.Properties.get\_PropertyAsString("SourceFolder").ToString();

&nbsp;&nbsp; **ASSUMPTIONS**

&nbsp;&nbsp; If sSourceFolder begins and ends with a percent (%) then I know the user set the value of the field to a variable.

&nbsp;&nbsp; When this is the case I can use Context.GetVariable(sSourceFolder.Replace("%","") &nbsp;to get the value to use in my code.

&nbsp;&nbsp; If sSourceFolder does not begin and end with a percent then I know the value entered is not a variable.

&nbsp;&nbsp;Can any verify if my assumptions are correct? &nbsp; &nbsp;

&nbsp;&nbsp;If my assumptions are correct, then I also need to take into account the situation where the user specifies multiple variables in a field. &nbsp; &nbsp; For instance, if the user set a field to %RootDir%\%Current Folder% then I would need to parse out the value and retrieve both variable values using the GetVariable() method.

&nbsp;&nbsp;Thanks&nbsp;

---

<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: [June 19, 2010, 12:55pm UTC](https://www.finalbuilder.com/forums/t/custom-action-retrieve-field-whose-value-is-a-variable/1505/2 "2010-06-19T12:55:34Z")

</div>

Hi Rob   
  
 Context.ExpandExpression is what you need to call. This will evaluate any variable references and provide the correct value back.
