Community
Showing results for 
Search instead for 
Do you mean 
Reply

Filtering opportunities of a contact

Copper Contributor
Posts: 133
Country: Netherlands

Filtering opportunities of a contact

I need to do a kind of Opportunity lookup for opportunities of contact X.

How can i achieve this? I cannot add a 'relatedtocontactx' FilterCrierium like I do for the rest of the criteria:

 

 

CriteriaColumn col = ACTFM.Lookups.GetCriteriaColumn(descriptor);
Criteria crit = new Criteria(LogicalOperator.And, 0, 0, col, OperatorEnum.Contains, value);
crits.Add(crit);



...



OpportunityLookup lookup = ACTFM.Lookups.LookupOpportunitiesReplace(crits.ToArray());

I can off course create a list of Guids with contact.GetOpportunities(null,null) and then do the lookup as above, and then loop through all matching opportunities and then foreach opportunity check if it's ID is in the  list, but that's rather slow and ugly.

 

I think I have to achieve this with the parameters for contact.GetOpportunities (which I am now giving null), but how? I could not find this. It's asking an IFilterCriteria, and I have Criteria objects...

 

How?

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Administrator
Posts: 1,312
Country: United_Kingdom

Re: Filtering opportunities of a contact

Is this still an issue you're looking for advice on? Did you manage to find a resolution in the end?
Copper Contributor
Posts: 133
Country: Netherlands

Re: Filtering opportunities of a contact

Yes, this is still an issue. For now I've implemented the 'slow and ugly' method as described above, but I feel there has to be a more elegant way.

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Administrator
Posts: 1,312
Country: United_Kingdom

Re: Filtering opportunities of a contact

I'll forward this thread on to our developer support team, hopefully they may have some ideas.
Moderator
Posts: 710
Country: USA

Re: Filtering opportunities of a contact

[ Edited ]

Unless I'm missing the scope of what you're doing, I would use GetOpportunitiesByContact() if it's available to you.

 

 *EDIT*

Yeah, just looking over this again, and I believe process is to get opportunities by contact method. (ACTFM.Opportunities.GetOpportunitiesByContact(Guid, IFilterCriteria[]) 

 

Remember, the framework follows many of the examples of the base product.  Act! doesn't have a Lookup Opportunities by Contact, so the framework won't as well.  Instead you can get opportunities for a specified contact, or get contacts for a specified opportunity, but you cannot use an Opportunity Lookup to get that information.

Billy Clark
Swiftpage
Act! Knowledgebase: http://kb.act.com
Copper Contributor
Posts: 133
Country: Netherlands

Re: Filtering opportunities of a contact

Okey thanks for the answer, but then what is GetOpportunitiesByContact's IFilterCriteria[] parameter used for? And how?

Greetings,

ACT Certified Consultants
TendenZ
the Netherlands
Moderator
Posts: 710
Country: USA

Re: Filtering opportunities of a contact

I haven't used this method before, but I'm working on an example now.  I'll get it to you as soon as possible.

Billy Clark
Swiftpage
Act! Knowledgebase: http://kb.act.com
Moderator
Posts: 710
Country: USA

Re: Filtering opportunities of a contact

Okay, so it works like this in essence:

 

In my example I'm passing the contact's ID (Which is a GUID) as a string (contact.ID.Tostring())

 

Knowing that a contact can have multiple opportunities, I have to take the opportunities I'm searching for as an array.

 

So since I know the GUID, I can get the array set up as such:

 

var opportunitiesForThisContact = ACTFM.Opportunities.GetOpportunitiesByContact(Guid.Parse(contact.ID.ToString()) ,new SortCriteria[] { } , new IFilterCriteria[] { });

foreach (Act.Framework.Opportunities.Opportunity opportunityFound in opportunitiesForThisContact)
{
  //do something here
  Console.WriteLine(opportunityFound.ID.ToString());
}

Now the sort and filter criteria are a different monster, but remember this is, in essence, a lookup.  So you can create additional sort/filter criteria just like what's in the product.  IE: sort by date, or filter by stage.

 

Carlton James has a great response in this thread which shows lookup criteria being used: (It's VB# but translates well)

https://community.act.com/t5/Act-Developer-s-Forum/Get-Contact-using-Lastname-firstname-as-filter-cr...

 

 

 

 

 

Billy Clark
Swiftpage
Act! Knowledgebase: http://kb.act.com
Copper Super Contributor
Posts: 483
Country: Australia

Re: Filtering opportunities of a contact

I do this bit to filter out "inactive opportunities"

The code is below if it helps

Also i am still working on the double Sort Criteria as that bit works with single but not double Sort

 

                            // Establish Opportunity List with inactive opportunities filtered out
                            int[] oSt2 = { 0, 1, 2 };
                            IFilterCriteria[] oFilterCriteria1 = { new InFilterCriteria(oStatus, oSt2) };
                            //STILL NEED A WORKING DOUBLE SORT
                            SortCriteria[] oSortCriteria1 = { new SortCriteria(oType, ListSortDirection.Descending), new SortCriteria(oAccNum, ListSortDirection.Descending) };
                            
                            OpportunityList cOpp = Act.UI.ActApplication.Instance.ActFramework.Opportunities.GetOpportunitiesByContact(cGUID, oSortCriteria1, oFilterCriteria1);

Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6