Showing results for 
Search instead for 
Do you mean 

Filtering by opportunity stage in a contact lookup

New Member
Posts: 2
Country: United_Kingdom

Filtering by opportunity stage in a contact lookup

I am using the following code to create a lookup that filters by a defined field in the contact record and the opportunity stage.


No errors are thrown but it also returns no results (when there should be many). Viewing the query xml generated by ACT it is also using the string "Complete" and it returns the correct results.


What am I missing here to get this lookup to evaluate correctly?



ActFramework objFramework = new ActFramework();
objFramework.LogOn(ACTconnection, ACTuser, ACTpass);

Act.Framework.Lookups.ContactLookup objContactLookup;
Act.Framework.Lookups.Criteria[] objsCriteria = new Framework.Lookups.Criteria[1];
Act.Framework.Lookups.CriteriaColumn objCriteriaColumn1;
Act.Framework.Lookups.CriteriaColumn objCriteriaColumn2;
objCriteriaColumn1 = objFramework.Lookups.GetCriteriaColumn("TBL_CONTACT", "CUST_WEBREFERENCE_021736533", true);

                    objCriteriaColumn2 = objFramework.Lookups.GetCriteriaColumn("VWT_OPPORTUNITY_STAGE_PROCESS", "STAGE",true);
                    objsCriteria[0] = new Framework.Lookups.Criteria(Framework.Lookups.LogicalOperator.And, 0, 0, objCriteriaColumn1, Framework.Lookups.OperatorEnum.ContainsData,Framework.Lookups.ValueEnum.Nothing);

                    objsCriteria[1] = new Framework.Lookups.Criteria(Framework.Lookups.LogicalOperator.End, 0, 0, objCriteriaColumn2, Framework.Lookups.OperatorEnum.EqualTo, "[Complete]");

                    objContactLookup = objFramework.Lookups.LookupContactsReplace(objsCriteria, false, false);

                    Act.Framework.Contacts.ContactList objContacts = objContactLookup.GetContacts(null);
Silver Super Contributor
Posts: 2,342
Country: USA

Re: Filtering by opportunity stage in a contact lookup

You are creating criteria for the Opportunity entity and then doing a lookup on the Contact entity.  You will need to create a lookup of Opportunities and then loop through them retrieving the associated Contacts and then create a lookup using that list of Contacts.  The easiest way to do it is to create an array of Contact Guids and then do a lookup on those Guids.



If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
Click Here to Purchase Act!