Showing results for 
Search instead for 
Do you mean 

Using Opportunity Fields (ACT 2010)

New Member
Posts: 2
Country: United States

Using Opportunity Fields (ACT 2010)

[ Edited ]

I've created a custom field called "Program Name" through the ACT! GUI.  I'm struggling to access the field through the SDK though.


Using the Framework, I’m able to identify the field.            

     Dim f As MutableEntities.MutableEntityFieldDescriptor           

     For Each f In ACTFWK.Opportunities.GetMutableEntityFieldDescriptors()               

       Debug.Print(f.ColumnName & ", " & f.DisplayName & ", " & f.TableName)               

       If f.Description = "Program Name" Then Exit For           


I can see the following information regarding f in the debug window:

           CUST_ProgramName_031511146, Program Name, TBL_OPPORTUNITY 


However, I’m not sure how to read this field or write to it.  Here’s my code to find and loop through the Opportunities.  It’s probably not the most efficient, but it works.            

     Dim opp As Opportunities.Opportunity           

     Dim cOpps As OpportunityList           

     Dim cColumn1 = ACTFWK.Lookups.GetCriteriaColumn("TBL_OPPORTUNITY.NAME", True)           

     Dim lCriteria() As Criteria = New Criteria() {New Criteria(LogicalOperator.End, CType(0, Byte), CType(0, Byte), cColumn1, OperatorEnum.ContainsData, ValueEnum.Nothing)}            

     cOppLookup = ACTFWK.Lookups.LookupOpportunitiesReplace(lCriteria)           

     cOpps = cOppLookup.GetOpportunities(Nothing)            

     For Each opp In cOpps               

          Debug.Print(opp.Name & ", " & opp.User1)           




I was looking for a method that would allow me to access this custom field that I added using a reference to the field identified above.                 Psuedocode:                               

     Debug.print Opp.Field(f).Value 


I attempted to             


with various combinations of names, and got an error every time I tried. (strFieldname = "TBL_OPPORTUNITY.CUST_ProgramName_031511146" or strFieldName = "Program Name" and even strFieldName = "TBL_OPPORTUNITY.NAME")




Could someone please point me in the right direction?  Are code examples available anywhere?





Message Edited by rlepard on 11-06-2009 03:19 PM
Nickel Elite Contributor
Posts: 937
Country: USA

Re: Using Opportunity Fields (ACT 2010)

[ Edited ]
There's a code example posted at: 
In this sample I look at the current opportunity record and get the value of the Weighted total field.  
You can ignore the OLEDB2 related function in this example as it's intended to show reading data from the provider (might be interesting but not what you're asking about here).
This code, like a lot of our samples, uses the .Net CurrencyManager to help provide the binding context.  Meaning the code expects to be executed when a specific opportunity is in context (e.g. when looking at the opp detail view).  
//This is the key part of the code -our class implements IMutableEntityListBoundControl so we have a listManager (which is a CurrencyManager)
// Here we cast our MutableEntityList into an OpportunityList letting us access the Opportunity properties 
OpportunityList cl = (OpportunityList)dataSource.MutableEntityList;
                    if (cl != null)
                        if (listManager != null)
                            listManager.PositionChanged -= new EventHandler(PositionChanged);
                            listManager.ItemChanged -= new ItemChangedEventHandler(ItemChanged);
//Here's the binding..
                        listManager = BindingContext[cl] as CurrencyManager;
                        listManager.PositionChanged += new EventHandler(PositionChanged);
                        listManager.ItemChanged += new ItemChangedEventHandler(ItemChanged);
                        OpportunityChanged(); // force a change since we're now bound
Later in the code...
//List Manager has a .Current which effectively gives your the current  OpportunityObject
  Opportunity currentOpportunity = listManager.Current as Opportunity; 
//Now you can use currentOpportunity as an instance of opp with the values of the current record
If you're writing a plugin or don't have that context with your control then you'll run your query and presumably store into an ArrayList - at that point Cast a new Opportunitylist and you can iterate through the array in a loop something like:
For Each opportunity As Act.Framework.Opportunities.Opportunity In oppList MsgBox(Opportunity.Fields("Opportunity.TotalWeighted", False)) 
 //I think this part is what you are looking for:
Opportunity.Fields("Opportunity.TotalWeighted", False)
Hope this helps. 
Message Edited by alduet on 11-06-2009 02:58 PM
Nickel Elite Contributor
Posts: 937
Country: USA

Re: Using Opportunity Fields (ACT 2010)

[ Edited ]

As a follow-up (I get this question occasionally) CurrencyManager has nothing to do with the data type currency or money in general.  Currency Manger is a method for managing the current state within a bound control.  Info on this Class can be found here: 


This site includes a couple of useful  examples of iterating through the bound list e.g. MoveNext()



Message Edited by alduet on 11-06-2009 02:50 PM