Community
Showing results for 
Search instead for 
Do you mean 
Reply

Replacements for obsoleted functions

Copper Contributor
Posts: 7
Country: United States

Replacements for obsoleted functions

I inhereted an app that used a previous version of the SDK (2008?) and am trying to get it to work with the 2010 SDK. I'm not even sure where to start on some of the obsoleted. For a simple example, I have a call to Opportunity(instance).RemoveProduct. The help consists only of

 

public void RemoveProducts( 
   Guid key,
   OpportunityProduct[] products
)

I have no idea what GUID it is looking for or how to get a OpportunityProduct array from the Opportunity. And then there are Methods that are not there at all anymore and have no apparent replacement, such as SetOpportunityField. Is there a document anywhere that may get me pointed in the right direction or is this going to have to be a complete re-write? I work with quite a few SDKs and this is, by far, the worst combination of poor help documents and lack of backward compatibility I've ever seen.

 

Employee
Posts: 1,163
Country: USA

Re: Replacements for obsoleted functions

[ Edited ]

Not knowing what your accomplishing it difficult to say whether or not a complete rewrite will be necessary. 

 

Opportunities did changed significantly between the 2009 and 2010 versions so hopefully that's the only place your running into obsolete methods.

 

The Guid parameter is the ID for the opportunity but I don't think you'll need it, here is an example I've hastily thrown together that will delete products from opportunities. 

 

 

OpportunityList ol = afw.Opportunities.GetOpportunities(null);

Opportunity o = ol[3];

 

CustomEntityList<OpportunityProduct> productList = o.GetProducts(null);

OpportunityProduct op = productList[0];

OpportunityProduct[] opRay = new OpportunityProduct[1];opRay[0] = op;

 

try

{

o.UpdateProducts(null, opRay);

}

catch (Exception x) { MessageBox.Show(x.ToString()); }

 

 

 

Message Edited by mwood on 04-06-2010 08:10 AM
Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 7
Country: United States

Re: Replacements for obsoleted functions

[ Edited ]

The problem I had with all the Get... functions is that the CustomEntityList class is not found, so  it won't event compile. I am using VS 2005 (not my choice) and a version of the SDK that may or may not be the most current. That class is not listed in the newest ACT! SDK help or C# MSDN library.

 

It also does not like any of my attempted commands of the form: (Assume opp is an instatiated Opportunity object and prodTot is a decimal value)

 

opp.Fields["ProductTotal"] = prodTot;

 

I am getting the name from the enumeration. I have tried all the Field collections and get the same error:

Invalid name format: ProductTotal

Parameter name: realName

Act.Framework

at Act.Framework.MutableEntities.MutableEntityMetaData.GetNameParts(String name, String& tableName, String& columnName)

at  ...

 

Message Edited by Bob Chaas on 04-07-2010 11:21 AM
Employee
Posts: 1,163
Country: USA

Re: Replacements for obsoleted functions

CustomEntityList should be part of the Act.Framework.CustomEntities namespace, but your right, my search on the index of the SDK reference documentation comes up empty, I'll have to look into that.

 

I ran into similar issues with Contact.Fields["Contact"] -- threw an identical error.

 

I had less issues working with field aliases, not sure if it's the same for Opportunities but Contact.Fields["Contact", Act.Framework.MutableEntities.FieldNameType.Alias]; got it done for me.

Matthew Wood
Act! SDK Support
Community Moderator
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Replacements for obsoleted functions

Hi Bob,

 

In your Project References, what version of the Act.Framework are you using?

 

I'm being a bit thick here so please bear with me, I can't work out if you mean you are using the ACT! 12 SDK documentation against the Act.Framework.dll for ACT! 2008 or the other way around or are using the ACT! 12 Act.Framework.dll and are trying to work against an ACT! 2008 installation! 

 

With regards to trying to get the Product Total for the Opportunity,  you could get the property ProductTotal:

 

decimal d = opp.ProductTotal; 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Copper Contributor
Posts: 7
Country: United States

Re: Replacements for obsoleted functions

Both the SDK and Framework I am talking about are version 12. The incomplete, no-comments, code that I am trying to get to work was written against 2008. I am making some progress, but continuing to hit road blocks. I'm also getting some weird stuff happening where members don't show up in the VS intellisense and then they do. Shortly after my last post the Product Total showed up. I know I looked for it many times and it was not there. I'm assuming thats some quirk of VS2005 and not spending any time figuring out the cause of that.

 

I was able to set the ProductTotal value.However, when I look at the ACT! interface, the Totals field in the upper left corner of the Detail view remains 0. If I do an opp.Update() (where opp is the instantiated Opportunity), then it doesn't save the Opportunity at all, or saves it to never-never land. I don;t see it in the UI anyway. My guess is that is a calculated field based on the sum of the added OpportunityProducts, although no error occured anywhere in the process.

 

Ignoring that for now, I was moving on to populating the OpportunityProducts. It appears that I need to fill an array of  OpportunityProduct instantiations and send it into the UpdateProducts method. I have everything coded for that to happen except making a blank OpportunityProduct. The constructor is looking for a parameter of type Act.Framework.CustomEntities.CustomSubEntity.CustomSubEntityInitializationState. I can find no valid values for that class, so that long road appears to have lead to a dead-end.

 

I'm trying to work things out the best I can before resorting to asking here. The problem with the Update for example, a person would almost need to see all the surrounding code to really be able to see any problems there. When I can isolate things down to specific commands, that's when I'd expect the people on this forum might be able to use their experience to possibly help me.

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Replacements for obsoleted functions

Hi Bob,

 

I feel your pain!

 

Anyway I have had a bit of look through the SDK and I think the design is towards not instantiating a new  OpportunityProduct object but to get a Product as a OpportunityProduct (I think I can see where they are coming form with this design in a way, but yes should be documented). So let's say we have our Opportunity opp and we know the "name" of the Product we want to associate with opp here we go:

 

 

ActFramework oFram;Opportunity opp; Product prod; ...

 

prod = oFram.Products.GetProduct("myProductStringName"); CustomEntityList<OpportunityProduct>myOppProds = oFram.Products.GetOpportunityProduct(prod.ID);

 So once you have the List<> you can do what you want with the contents etc and finally call a opp.UpdateProducts(myOppProd,null);

 

HTH 


 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Copper Contributor
Posts: 7
Country: United States

Re: Replacements for obsoleted functions

The only problem I have with that approach is I would have to assume the product is already in the ACT! DB and it may not be.  It sure would be nice if I could just create an empty OpportunityProduct and populate it.
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Replacements for obsoleted functions

I can't think of a single application use case scenario where you could have an OpportunityProduct object without an associated Product, unless of course you have some strange level of corruption.

 

If however you are presented possibly with the name of a Product that is not part of the product list you could of course check for null through the returned ProductList via the ProductManager.GetProducts().

 

It might be an idea to have a quick read through the Application Help files to get an idea of how Opportunities and Products are used within ACT!. 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Copper Contributor
Posts: 7
Country: United States

Re: Replacements for obsoleted functions

I have been looking at the Help file, but the index doesn't work, there are no code samples, and no real overview. It's like trying to learn to speak a foreign language with only a dictionary. Using what info was in the help and a lot of trial and error, I did find a solution. I was going to post in a separate thread