# Set strings collection property from custom action

**URL:** https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332
**Category:** Discussion
**Created:** [January 25, 2007, 10:23am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332 "2007-01-25T10:23:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jhunsaker](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jhunsaker](https://www.finalbuilder.com/forums/u/jhunsaker)
#### Post date: [January 25, 2007, 10:23am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/1 "2007-01-25T10:23:01Z")

</div>

I’m implementing a custom action using C#.Net 2.0. I need to return a collection of strings from the OnExecute() method. However, the Context (IFBCustomActionExecuteContext) doesn’t appear to expose a method or property to achieve this. I was expecting:   
  
Context.Properties.set\_PropertyAsStrings(“MyProperty”, someArray);  
  
but there is no “set” for the collection (just bool, double, int, string, variant). How can I accomplish returning a collection (like List Iterator does)?  
  
Thanks!

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [January 29, 2007, 11:46am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/2 "2007-01-29T11:46:57Z")

</div>

Hi Jeff,  
  
The PropertyAsStrings properties are actually IFBStrings objects, which have their own interface for access. Rather than replacing the entire object, you can work with it. Unfortunately, the interface is missing a couple of useful methods - namely Clear and an AddCollection() method. You’ll need to work around it like this:  
  
IFBStrings mystrings = Context.Properties.get\_PropertyAsStrings(“SomeProperty”);  
while(mystrings.Count \> 0)  
{  
 mystrings.Delete(0);  
}  
foreach(string s in myCollection)  
{  
 mystrings.Add(s);  
}  
  
I’ll add a Clear() and a SetCollection() method to the to-do list for the next major release.  
  
Regards,  
  
Angus

---

<div class="post-metadata">

### Author: ![jhunsaker](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jhunsaker](https://www.finalbuilder.com/forums/u/jhunsaker)
#### Post date: [March 9, 2007, 11:15am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/3 "2007-03-09T11:15:14Z")

</div>

Does anything appear incorrect in this code block? I know the IFBStrings object is populated properly because I’m logging it. However, the variable I’m setting through the action’s “Systems” Strings (note the plural) property remains empty.   
  
  
 string[] systems = new string[2] { “system1”, “system2” }; // just as an example  
 IFBStrings fbSystems = Context.Properties.get\_PropertyAsStrings(“Systems”);  
  
 foreach (string s in systems)  
 {   
 fbSystems.Add(s);  
 }  
  
 Context.SetVariable(Context.Properties.get\_PropertyAsString(“Systems”), fbSystems);  
  
  
Thanks.

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [March 12, 2007, 6:26am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/4 "2007-03-12T06:26:31Z")

</div>

Hi Jeff,  
  
What are you trying to achieve with the Context.SetVariable() call? SetVariable sets a FinalBuilder variable inside the FinalBuilder runtime, not inside the Action itself. Do you just want to write the values in fbSystems “back” to the action property? If so, there is no need - fbSystems will be a reference to the property on the action (they’re both the same object.) Attempting to retreive an object of type IFBStrings as a String, and then use it as a variable name, is very unwise.  
  
Regards,  
  
  
Angus

---

<div class="post-metadata">

### Author: ![jhunsaker](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jhunsaker](https://www.finalbuilder.com/forums/u/jhunsaker)
#### Post date: [March 12, 2007, 10:57am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/5 "2007-03-12T10:57:13Z")

</div>

Well I don’t want to pursue the unwise! Here’s what I need to accomplish: I have an array within my .Net 2.0 custom action. I need to return the values within this array as a FB property back to the FB project. I have a Strings FB Property named “Systems”. How can I accomplish this?   
  
Further, is this the proper method of populating variables tied to properties of a custom action?   
  
Thanks.

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [March 13, 2007, 12:29pm UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/6 "2007-03-13T12:29:28Z")

</div>

Hi Jeff,  
  
Glad to know you’re keeping away from the unwise. ;-).   
  
Here’s how I would do this:  
  
1) Add a property to your custom action in ActionStudio. Make the property of type “String” and call it something like “SystemsVariable”.   
  
2) Place a “Variable ComboBox” control on the property page for the aciton and bind it to “SystemsVariable”.  
  
3) Add a label to the combobox, something like “Save Systems to Variable"  
  
4) In the assembly, put some code like this  
  
string[] systems = new stringΐ] { “system1”, “system2” }; // just as an example  
  
string sysVariable = Context.Properties.get\_PropertyAsString(“SystemsVariable”);   
string systemString = String.Join(”\r\n", systems);  
  
Context.SetVariable(sysVariable, systemString);  
  
  
… at runtime, the above code will populate the chosen variable specified in the “SystemsVariable” property with the contents of the systems array, as a CRLF-delimited string. CRLF-delimited strings are more useful in almost all cases where FinalBuilder actions use “list” type items (List Iterator, Prompt For Variables combo boxes, etc.)  
  
Please let me know if I’ve missed the point somehow.  
  
Regards,  
  
Angus

---

<div class="post-metadata">

### Author: ![jhunsaker](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/j/b3f665/32.png) [@jhunsaker](https://www.finalbuilder.com/forums/u/jhunsaker)
#### Post date: [March 14, 2007, 3:40am UTC](https://www.finalbuilder.com/forums/t/set-strings-collection-property-from-custom-action/332/7 "2007-03-14T03:40:16Z")

</div>

Perfect. That did it. I wasn’t grabbing the variable as well as trying to return a property of Strings instead of just String.   
  
Thanks.
