Community
Showing results for 
Search instead for 
Do you mean 
Reply

Modify Company and contact access via Visual Basic Coding

Copper Super Contributor
Posts: 71
Country: Canada

Modify Company and contact access via Visual Basic Coding

I was wondering if anyone knew how to change the company access and contact access of linked contacts to that company to public through visual basic coding. And have the event trigger when you leave the contact/compnay if the ID/Status is set to say "Landlord".

Employee
Posts: 1,163
Country: USA

Re: Modify Company and contact access via Visual Basic Coding

I don't have anything in VB, but I will post here an example of how to change a contacts access to public.

 

 Contact c = _ActApp.ApplicationState.CurrentContact;
            if (c.CanChangeAccessType)
            {
                c.AccessType = AccessType.Public;               
                c.Update();
            }

 

Hooking into the contact/company changed event should be pretty straightforward and within them we just need to capture the field descriptor for ID/Status and compare the value.

 

ActApp.CurrentContactChanged += new EventHandler(ActApp_CurrentContactChanged);

 

VS should auto generate the method stub, if you need help getting field descriptors there are a bunch of examples on the forum, if you have any trouble though just update this thread.

Contact c = _ActApp.ApplicationState.CurrentContact;
Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Modify Company and contact access via Visual Basic Coding

That worked perfectly thank you! Another off the topic question, I am using the field changed event to run code when a field changes however it always pulls in the full fieldname for example if I have address 1 in my database it pulls in 

TBL_CONTACT.BUSINESS_LINE1, if there any way to have it so that it pulls in the display name of the field that is currently changed?

Employee
Posts: 1,163
Country: USA

Re: Modify Company and contact access via Visual Basic Coding

I don't think there is a way for the FieldChanged event to pass you the display name rather than the real name since it's passing it as a string and not as an actual FieldDescriptor. Once we've captured the FieldDescriptor from the string we can get it's display name though, but you probably knew that.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Modify Company and contact access via Visual Basic Coding

Sorry I am unfirmiliar with that, so once we pull real name into a string from the field changed event how do you use the fielddescriptor to get the display name.

Employee
Posts: 1,163
Country: USA

Re: Modify Company and contact access via Visual Basic Coding

This is just off the top, I don't have VS in front of me. But once you have a string with the fields real name, you simply use your GetContactFieldDescriptor method (if you in contacts) to get a field descriptor from the string. Once there, display name is a property of a ContactFieldDescriptor object.

Matthew Wood
Act! SDK Support
Community Moderator