Community
Showing results for 
Search instead for 
Do you mean 
Reply

How to get maximum size of a Contact Field

New Member
Posts: 6
Country: Canada

How to get maximum size of a Contact Field

[ Edited ]

Hi,

 

I've been trying to get the max size of a contact field, so that when I sync my source data I don't go over the ACT fields' capacities.

 

I was wondering why my data wasn't saving to my ACT db, but then I realized my FieldDescriptor object remains null. My ContactFieldDescriptor object does populate properly, using the same reference name, and what I'm doing below is what I read I should do to be able to fetch the FieldDescriptor object, which in turns gives me access to GetSize(), which does not exist in ContactFieldDescriptor.

 

But in the end, what I really want to have is the maximum size of the field.

 

Thanks for your help!

 

Code Sample:

// Prepare ACT field
                            String sActFieldName = "TBL_CONTACT." + assoc.actFieldName;
                            ContactFieldDescriptor cfd = framework.Contacts.GetContactFieldDescriptor(sActFieldName);
                            FieldDescriptorCollection cField = framework.Fields.GetFields(RecordType.Contact);
                            FieldDescriptor fd = cField.Find(sActFieldName);
                            
                            if (cfd != null && fd != null)
                            {
                                // Prepare value
                                String value = ((pi.GetValue(exContact, null) == null) ? "" : pi.GetValue(exContact, null).ToString());
                                value.Remove(fd.GetSize());

                                // Assign field value to ACT Contact
                                cfd.SetValue(actContact, value);
                            }

 

 Thanks,

Mathieu

Employee
Posts: 1,163
Country: USA

Re: How to get maximum size of a Contact Field

Since here you have the same field as both a DBFieldDescriptor and a FieldDescriptor, couldn't you use the GetSize() method to return the maximum length and then compare that to the data coming from your source?

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 6
Country: Canada

Re: How to get maximum size of a Contact Field

Hum, maybe i'm understanding it wrong, but isn't it what I'm doing (trying to do) already?

 

I'm calling the GetSize() method of the FieldDescriptor object for the sole reason that GetSize() does not exist for ContactFieldDescriptor.

 

The thing is, when I try to obtain the FieldDescriptor object using the reference name, the Find() method returns null.

Employee
Posts: 1,163
Country: USA

Re: How to get maximum size of a Contact Field

When you debug through are you able to see the field in the FieldDescriptor collection? My guess is that the string value we're using for Find, doesn't match and that's why it's not finding the field.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 6
Country: Canada

Re: How to get maximum size of a Contact Field

Hi Matt,

 

Good idea, but it seems to be quite there as seen in the following screenshot:

http://screencast.com/t/TbMK8LfC

 

Following your idea, I have double-checked to see if the Find() method would work if I stripped the 'TBL_CONTACT' portion that is necessary for getting the ContactFieldDescriptor object, but the Find() method still returns null.

 

The screenshot doesn't include this visual, but when I point the assoc.actFieldName or sActFieldName variables, I really get 

"CUST_FaxNumber_064743182" and 

"TBL_CONTACT.CUST_FaxNumber_064743182" respectively.

 

Please advise.

 

Mat

New Member
Posts: 6
Country: Canada

Re: How to get maximum size of a Contact Field

Update:

 

I was able to fetch the FieldDescriptor object by switch from using Find() to using FindByColumnName(), and still leaving out the table name (TBL_CONTACT) from the criteria.

 

Thanks!

Mat

 

New Member
Posts: 6
Country: Canada

Re: How to get maximum size of a Contact Field

Hi,

 

So I get a value, but it seems the value I receive is not always valid? My specific example is with the Time Zone field.

 

In the FieldDescriptor.GetSize() method, I get a value of 100:

http://screencast.com/t/aED9Ix2gXOlx

 

But then when it goes through to apply the value to the Contact's field, I get this exception. Max size of 50?

http://screencast.com/t/UqPke4du

 

So, how should I get that real field max size of 50, so I can manage it and avoid encountering these exception messages?

 

Thanks!

Mathieu

Employee
Posts: 34
Country: USA

Re: How to get maximum size of a Contact Field

Instead of GetSize, try GetLength.  I think that will give you the value you want. 

New Member
Posts: 6
Country: Canada

Re: How to get maximum size of a Contact Field

Resolved! Thanks for your assistance.

 

Mat