12-12-2017 03:19 AM
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?
01-11-2018 02:52 AM
01-22-2018 05:56 AM
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.
01-22-2018 06:28 AM
01-22-2018 12:35 PM - edited 01-22-2018 01:20 PM
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.
01-23-2018 01:46 AM
Okey thanks for the answer, but then what is GetOpportunitiesByContact's IFilterCriteria[] parameter used for? And how?
01-23-2018 05:21 PM
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.
01-24-2018 09:05 AM
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)
02-01-2018 02:59 PM
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);