03-17-2011 03:27 PM
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.
03-18-2011 06:50 AM
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.
03-18-2011 08:03 AM
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.
03-18-2011 08:46 AM - edited 03-18-2011 08:48 AM
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 = _ActApp.ActFramework.Contacts.GetMyRecord().ID;
idRay = _ActApp.ApplicationState.CurrentContact.ID;
03-18-2011 12:43 PM
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.
03-18-2011 01:19 PM
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.
03-18-2011 01:41 PM
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.
03-18-2011 01:54 PM
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 C_List() as ContactList
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.UpdateContactGUIDs() As Guid
This is the last hurdle before getting this thing to work. (I am using VB .NET) Thanks.