Community
Showing results for 
Search instead for 
Do you mean 
Reply

Associate a Contact with a new Opportunity

New Member
Posts: 12
Country: USA

Associate a Contact with a new Opportunity

I have read as many posts as I can find, but am not finding the solution I need.  I can create an Opportunity and add a prodcut, but I cannot figure out how to associate a Contact to the new Opportunity.

 

I am using the ACT Framework (EXE files) instead of the ACT Application SDK. However, I may need it for the ACT Application as well.

 

Also, I am using VB .NET.  Thanks.

Employee
Posts: 1,163
Country: USA

Re: Associate a Contact with a new Opportunity

Regardless if your doing it throught he UI or the framework the method used is the same. Opportunity.UpdateContacts(Guid[] added, Guid[] removed), then update the opportunity.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

I do not want you to do too much work, but I have not used GUIDs, so could you provide more detailed code?  I have the Opportunity created, so I would just need the GUID of the Current Contact.  How do I get that GUID?  I will also look at other posts to see if I can find the answer without too much trouble from you.  Thanks for anything you can give me.

Employee
Posts: 1,163
Country: USA

Re: Associate a Contact with a new Opportunity

[ Edited ]

It's not a problem at all, but it'll be in c#.

 

I'll assume you can create an array of Guid's, once you have this you can assign the value of one of the indeces to a contact, the following will get the ID for the MyRecord account. All Contact objects have an ID property. idRay isn't initialized here but it is simply an array of Guid's.

 

idRay[0] = _ActApp.ActFramework.Contacts.GetMyRecord().ID;
//Current contact
idRay[1] = _ActApp.ApplicationState.CurrentContact.ID;
Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

Thanks.  I did not realize it was that simple.  Appreciate the help!!!

New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

Sorry to bother you again, but I have another question regarding Opportunity fields.  I cannot get the right code to set the Opportunity User Fields with the SDK.  I am trying oppID.Fields("USER1",true) and any other combination that I can think of, but the code keeps erroring on Bad Name.

 

Would appreciate a hint as to how to set values on the Opp User Fields.  Thanks.

Employee
Posts: 1,163
Country: USA

Re: Associate a Contact with a new Opportunity

You can get the DBFieldDescriptor for the User1 opportunity field like this:

 

DBFieldDescriptor dbf = _ActApp.ActFramework.Opportunities.GetFieldDescriptor("TBL_OPPORTUNITY.USER1");

From there you can call the field descriptors SetValue method, if I remember correctly the first parameter is the value and the second is the object you want to change it for, in this case, an opportunity.

Matthew Wood
Act! SDK Support
Community Moderator
New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

I don't think that is it.  That code works for setting a Contact field, but there is no SetValue option for an Opportunity.

 

In ACT 2006, there was newOpp.SetOpportunityField(<field number, 0-7>, <value to set>), but I cannot find a corrsponding funtion for this version of ACT.

 

Do you have another thought.  Thanks.

New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

Actually, I am still having trouble with associating a Contact to an Opportunity.  This is what I am doing.  I hope you can quickly see my mistake:

 

Dim 

Dim C_List() as ContactList

<various code>

Get Contact - puts the Contact in C_List(0)

ContactGUIDs(0) = C_List(0).ID - this is where the Plugin stops working, so I never get to the reset, but interestied in your opinion if I am doing the association properly below

<various code including creating a new Opp>

newOpp.UpdateContacts(ContactGUIDs,True)

newOpp.Update

ContactGUIDs() As Guid

 

This is the last hurdle before getting this thing to work.  (I am using VB .NET)  Thanks.

New Member
Posts: 12
Country: USA

Re: Associate a Contact with a new Opportunity

Somehow, the last post got mixed up.  The last line really is at the end of the first line (the dim for the ContactGUID)