Community
Showing results for 
Search instead for 
Do you mean 
Reply

filter search results by date.

Accepted Solution Solved
New Member
Posts: 8
Country: USA
Accepted Solution

filter search results by date.

Hi there, So I have a web sales portal I built using the act SDK and c# asp.net. I currently can have a search function built in that makes things pretty simple but I would like to be able to expand its abilities. my current code is below.

 

    public static ContactFieldDescriptor GetCFD(string displayName)
    {
        ActFramework FW = new ActFramework();

        FW.LogOn;
        ContactFieldDescriptor[] arFd = FW.Contacts.GetContactFieldDescriptors();

        foreach (ContactFieldDescriptor cfd in arFd)
        {
            if ((cfd.DisplayName.ToLower().Equals(displayName.ToLower())))
            {
                return cfd;
            }
        }
        //Log error as necessary
        return null;

    }
    public static ContactList Search(string data, string CFD)
    {
        GC.Collect();
        ContactList Clist;
        ActFramework FW = new ActFramework();

        FW.LogOn;
        ContactFieldDescriptor mefd = GetCFD(CFD);


        CriteriaColumn col = FW.Lookups.GetCriteriaColumn(mefd);
        Criteria[] crit = new Criteria[1];
        crit[0] = new Criteria(LogicalOperator.End, 0, 0, col, OperatorEnum.Contains, data);
        try
        {
            ContactLookup oppLookup = FW.Lookups.LookupContactsReplace(crit, false, false);
            Clist = oppLookup.GetContacts(null);
            return Clist;
        }
        catch (Exception ex)
        {
            string error = ex.ToString();
            string errorTrace = ex.StackTrace.ToString();
            email.sendError(error, errorTrace);
            return null;
        }
    }

 

Using that I can successfully search for a contact by what ever method I determine fit (Email, Customer number, Phone number etc)

 

What I would like to be able to do is input a Reports function so I can pass multiple variables and then refine it even more.

 

Examples would be I would like to pull all customers signed by ROOM 1 then be able to refine that by a date range and maybe even a third variable like what merchant they used (of course those are all custom field descriptors so I would implement them accordingly) just need help getting the logic down.

 

Thanks so much I'm using ACT Pro v16.

 

Ryan Lewis


Accepted Solutions
Solution
Accepted by topic author Ryanlewis2010
‎01-18-2016 08:28 PM
Silver Super Contributor
Posts: 2,328
Country: USA

Re: filter search results by date.

Yes.  There is some sample code in this post that uses a multi parameter array for criteria.  Yours would work the same way.

 

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

 

Stan


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

View solution in original post


All Replies
Silver Super Contributor
Posts: 2,328
Country: USA

Re: filter search results by date.

You just need to extend your criteria definition so that it can include more parameters.  There are examples posted in this forum and the SDK documentation demonstrating how to do it.


Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
New Member
Posts: 8
Country: USA

Re: filter search results by date.

Can you by any chance link to one of them? the search function on the forum is horrid. As for the SDK I'm trying to see if there is anything I can find in there the v16 doesn't look like it has anything on it.;
New Member
Posts: 8
Country: USA

Re: filter search results by date.

[ Edited ]

I'm assuming and ill try to see but let me know if I'm on the right path, I would turn this line

crit[0] = new Criteria(LogicalOperator.End, 0, 0, col, OperatorEnum.Contains, data);

into a array with multiple criteria?

 

Solution
Accepted by topic author Ryanlewis2010
‎01-18-2016 08:28 PM
Silver Super Contributor
Posts: 2,328
Country: USA

Re: filter search results by date.

Yes.  There is some sample code in this post that uses a multi parameter array for criteria.  Yours would work the same way.

 

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

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
New Member
Posts: 8
Country: USA

Re: filter search results by date.

[ Edited ]

Thanks so this is what I have right now:

ActFramework FW = new ActFramework();

        FW.LogOn(@"");
        
        ContactFieldDescriptor mefd = GetCFD(CFD);


        CriteriaColumn column1 = FW.Lookups.GetCriteriaColumn(mefd);
        CriteriaColumn column2 = FW.Lookups.GetCriteriaColumn("TBL_CONTACT.CREATEDATE", true);

        //create intividual criteria items using criteria columns
        dynamic cList = new List<Criteria>();
        Criteria c1 = new Criteria(LogicalOperator.And, 0, 0, column1, OperatorEnum.Contains, "data");
        Criteria c2 = new Criteria(LogicalOperator.End, 0, 0, column2, OperatorEnum.Between, date1, date2);
        cList.Add(c1);
        cList.Add(c2);

        //convert the list to an array
        Criteria[] cArray = cList.ToArray();

        try
        {
            ContactLookup contactLookup = FW.Lookups.LookupContactsReplace(cArray, true, true);

            ContactList contactList = contactLookup.GetContacts(null);

            return contactList;
        }
        catch (Exception ex)
        {
            string error = ex.ToString();
            string errorTrace = ex.StackTrace.ToString();
            email.sendError(error, errorTrace);
            return null;
        }
    }

the only problem is I keep getting a null result so my question is, what is the best way to get the createdate CFD? Because if I run this same code with out the between and createdate it runs perfect and returns all with matching data.