Community
Showing results for 
Search instead for 
Do you mean 
Reply

Get contact address line

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

Get contact address line

Ok so i've been going nuts trying to get the contact address line from a contact in C#. I've seen a bunch of posts about how to do it in VB but I'm unable to get them converted correctly. I can get the LastName and FirstName but not the rest of the fields. From what I can tell it has to do with using the contact.Fields entry but this code:

 

 

 

//c#
 Contact currContact= application.ApplicationState.CurrentContact;
 //get the address 1 field value
 string Add1 = (string)currContact.Fields["Contact.Address 1", false];

 

 

 

 

Gives me an error box in act:  "Invalid column name:  Address 1" "Parameter name: realName"

 

I know i'm missing something simple about retrieving these fields and am wicked frustrated trying to find the answers! 

 

 


Accepted Solutions
Solution
Accepted by topic author mluich
‎09-25-2015 03:20 AM
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Get contact address line

Hi Mike,

 

Yeah sorry. Try this:

 

string add1 = (string)currContact.Fields["Address_1", Act.Framework.MutableEntities.FieldNameType.Alias];

 

This way you explicitly tell the framework to use the Alias name and you can forget about getting the correct table etc.

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog

View solution in original post


All Replies
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Get contact address line

Hiya,

I think you might have a typo in the field name. Try putting in an underscore: "Address_1".
Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 3
Country: USA

Re: Get contact address line

Nope,

    That just updates the Error message to include the underscore.

 

Mike

Solution
Accepted by topic author mluich
‎09-25-2015 03:20 AM
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Get contact address line

Hi Mike,

 

Yeah sorry. Try this:

 

string add1 = (string)currContact.Fields["Address_1", Act.Framework.MutableEntities.FieldNameType.Alias];

 

This way you explicitly tell the framework to use the Alias name and you can forget about getting the correct table etc.

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
New Member
Posts: 3
Country: USA

Re: Get contact address line

That Did it,

 

And It's making a bit more sense. The Act.Framework.MutableEntities.FieldNameType.Alias is the trick.

 

Thanks soooo much. I was starting to get a bruise on my head from this one.

 

Mike