Reply
New Member
mramu1310
Posts: 17
Country: India
Message 1 of 6 (1,689 Views)

Creating Opportunity through Code.

Hi,

 

I want to create an opportunity using SDK.  I wrote code in Visual studio 2005 and i am using ACT version 10.0.1.199.

 

We can create an opportunity by using one of the 5 overload methods. I am able to create opportunity by using first two overloads (those which doesnt have products info, compititor, source, users etc).

 

When i am trying to create an opportunity using any of the remaining three overloaded methods, it is saying "object reference is not set to instance of Object".

 

In Act we can create an opportunity with out users, grouplist etc. Here i am passing values to all parameters except users. for users i am passing null.

 

Anybody please help me how to create an opportunity using any one of the remaining overloaded methods.

 

Thanks in Advance.

 

 

Thanks and Regards

Ramu

Please use plain text.
Employee
tfaust
Posts: 33
Country: USA
Message 2 of 6 (1,685 Views)

Re: Creating Opportunity through Code.

Without seeing your code it is hard to say, but it sounds like there is some confusion over what is expected for overloads that want a "Act.Framework.Users.User" as a parameter. This parameter is named "manager" and is the owner of the opportunity, not really a contact to associate with the opportunity. Try passing in ActFramework.CurrentUser for this parameter.
Tim Faust
ACT! R&D
Please use plain text.
New Member
mramu1310
Posts: 17
Country: India
Message 3 of 6 (1,675 Views)

Re: Creating Opportunity through Code.

Thank you very much for your response.

 

It worked for me.

 

would you please tell me how to add existing products to opportunity using OpportunityProductInfo?

 

Thanks

Ramu

Please use plain text.
Employee
tfaust
Posts: 33
Country: USA
Message 4 of 6 (1,656 Views)

Re: Creating Opportunity through Code.

Since I don't know what you are really trying to do I can only answer it generically. Create an OpportunityProductInfo array and populate it with OpportunityProductInfo objects prefilled with information from whatever products you want to add. To get the list of products in the database:

 

ProductList prodList = af.Products.GetProducts(null);

 Once you locate the correct Product in the ProductList ,you can use that product's properties to set the corresponding OpportunityProductInfo object properties. Remember that Products are just templates, there is no real linkage to OpportunityProducts and you can set the properties however you like and it will affect no other Opportunity that uses those same products.

 

 

 

Tim Faust
ACT! R&D
Please use plain text.
New Member
mramu1310
Posts: 17
Country: India
Message 5 of 6 (1,633 Views)

Re: Creating Opportunity through Code.

Thank you very much.

 

I did the same thing. Here I am looking for a effective solution to get the particular product (using query) instead of getting all the products in productList. Is there any method to achieve this?

 

Thanks in Advance. 

 

 

Thanks and Regards

Ramu

Please use plain text.
Employee
tfaust
Posts: 33
Country: USA
Message 6 of 6 (1,585 Views)

Re: Creating Opportunity through Code.

Not really.

 

Once you have a product list you can find within it though. For example if you want to find a certain product name you could do something like this:

 

 

... int index = prodList.Find(new ProductFieldDescriptor(ProductField.Name), "NametoFind"); if (index != -1) { Product p = prodList[index]; ... } ...

 

 

 

Tim Faust
ACT! R&D
Please use plain text.