Community
Showing results for 
Search instead for 
Do you mean 
Reply

What are the steps to update a single opportunity record's fields using the SDK

Avid Listener
Posts: 9
Country: United States

What are the steps to update a single opportunity record's fields using the SDK

I'm using ACT Version 12.0.0.401

 

I'm writing in vb.net (a visual studio 2005 app)

 

I've been able to create new contacts and opportunities, create associations, query, etc.

 

If I want to update a single opportunity record and know it's opportunityID, how do I locate the record and place values into it's fields. The fields to be updated are both original (out of the box) opportunity fields and new added fields.

 

A code snippet that includes the locating/pointing to an opportunity record as well as a field being updated would be greatly appreciated.

 

Thanks in advance!

Employee
Posts: 1,163
Country: USA

Re: What are the steps to update a single opportunity record's fields using the SDK

[ Edited ]

You can use

 

OpportunityList myOppList = ActApp.ActFramework.Opportunities.GetOpportunitiesByID(null, oppGuid);

 

to retrieve an opportunity by ID

 

//isolate this opportunity from the list

Opportunity myOpp = myOppList[0];

 

With this opportunity object you can set it's various fields either like this:

myOpp.Name = "";

 

or

 

myOpp.Fields["Company", true] = "";

 

once you've made your desired changes just call the update method for said opportunity.

 

Matthew Wood
Act! SDK Support
Community Moderator
Avid Listener
Posts: 9
Country: United States

Re: What are the steps to update a single opportunity record's fields using the SDK

Mathew,

 

   Thanks for the quick response!

 

    I spent time converting your example to vb and encountered a little difficulty:

 

1)  What type of object is oppGuid? An array, memory variable, ACT object?

2) Any chance you could provide the same example in VB? My C->VB skills aren't strong.

 

Thanks in advance, I appreciate it!

 

      - John

Employee
Posts: 1,163
Country: USA

Re: What are the steps to update a single opportunity record's fields using the SDK

1) System.Guid, it's simply the ID of the specified opportunity. I chose to look up opportunities this way because you mentioned that you knew it's ID.

2) I probably could, but it'll take a me a few, I'll see if I can't get something up here this afternoon
Matthew Wood
Act! SDK Support
Community Moderator
Employee
Posts: 1,163
Country: USA

Re: What are the steps to update a single opportunity record's fields using the SDK

Dim myOppList As OpportunityList = _afw.Opportunities.GetOpportunities(Nothing)
Dim id As Guid = myOppList.Item(0).ID

Dim opp As Opportunity = myOppList.Item(0)
opp.Name = "New Name"
opp.Fields.Item("Company", True) = "New Company Name"
opp.Update()
Matthew Wood
Act! SDK Support
Community Moderator
Avid Listener
Posts: 9
Country: United States

Re: What are the steps to update a single opportunity record's fields using the SDK

Matt,

 

  Thanks again for the quick replies!

 

  In your last example (thanks for the VB by the way), where do you use a known opportunity ID (guid)?

 

  I have the ID (as a GUID) in a memory variable for example.

 

  Thanks again!  Huge help!

 

          - John

Employee
Posts: 1,163
Country: USA

Re: What are the steps to update a single opportunity record's fields using the SDK

You just need to create an array of Guid's, and populate it with the known ID's and then you can use it as the second parameter.

Dim ids(1) As Guid
ids(0) = opp.ID
Dim oppByID As OpportunityList = _afw.Opportunities.GetOpportunitiesByID(Nothing, ids)
Matthew Wood
Act! SDK Support
Community Moderator
Avid Listener
Posts: 9
Country: United States

Re: What are the steps to update a single opportunity record's fields using the SDK

Matt,

 

    That last post totally got me through it. Thanks for the quick replies!

 

       - John