Community
Showing results for 
Search instead for 
Do you mean 
Reply

v16 - Retrieve contact - weird error

Astute Commentator
Posts: 18
Country: USA

v16 - Retrieve contact - weird error

[ Edited ]

Hi

 

Since upgrading to v16 a piece of code has stopped working and performs in a weird fashion, and it's driving me nuts!

 

The "Search" function finds the correct contact record and in debug I can see that the variable "result" has all the contact fields (name, email address etc.)

 

When this function returns then the "contact" variable throws Null Exceptions for all properties even though it is declared as the same type (Contact type).

 

This is all .NET4 VS2010 and was working fine before upgrading to v16.

 

The code is all in the same project and the correct Act DLLs are being referenced.

 

Any help is greatly appreciated!

 

 Thanks.

 

            Contact contact = ActDataProxy.Search(new ContactSearchCriteria { EmailAddress = dto.EmailAddress });

 

        public static Contact Search(ContactSearchCriteria filter)
        {
            Contact result = null;
 
            using (var framework = GetActFramework())
            {
                Act.Framework.Lookups.CriteriaColumn searchColumn = null;
                OperatorEnum equalOperator = OperatorEnum.Contains;
                string searchValue = string.Empty;
 
                if (!string.IsNullOrEmpty(filter.EmailAddress))
                {
                    searchColumn = framework.Lookups.GetCriteriaColumn(GetContactFieldDescriptor(framework, "e-mail"));
                    searchValue = filter.EmailAddress;
                }
                else if (!string.IsNullOrEmpty(filter.Fullname))
                {
                    searchColumn = framework.Lookups.GetCriteriaColumn(GetContactFieldDescriptor(framework, "contact"));
                    searchValue = filter.Fullname;
                }
 
 
 
                Criteria[] criteria = new Criteria[]{
                                            new Criteria(LogicalOperator.End, (byte)0, (byte)0, searchColumn, equalOperator, searchValue)           
                };
 
                ContactLookup lookup = framework.Lookups.LookupContactsReplace(criteria, truetrue);
                Act.Framework.Contacts.ContactList list = lookup.GetContacts(null);
 
 
                //
                // Build return object
                //
                if (list != null)
                {
                    foreach (Act.Framework.Contacts.Contact actContact in list)
                    {
                        result = actContact;
                        break;
                    }
                }
 
 
            }
 
 
            return result;
        }
Astute Commentator
Posts: 18
Country: USA

Re: v16 - Retrieve contact - weird error

Update:

 

It seems that in v16 when the "using (var framework..." statement goes out of scope then the Contact object is lost.

 

If I move the "framework" variable up a level and pass it into the "Search" function then the returned Contact object in the "contact" variable is now available and correct.

 

This didn't happen on my previous version (ACT2010).

 

Hey-ho!