Community
Showing results for 
Search instead for 
Do you mean 
Reply

Products.CreateProduct

Bronze Super Contributor
Posts: 1,231
Country: USA

Products.CreateProduct

 

I have found the way to add a product into the master product list by...

Me.HostFramework.Products.CreateProduct(Name, ItemNumber, Price, Cost)

 

Is there a way I can update this product?

Is there a way I can delete this product?

 

Is there a difference between ACT! 10.11 and ACT 12?

 

Thanks

-- Jim Durkin 

 

Copper Super Contributor
Posts: 59
Country: USA

Re: Products.CreateProduct

Hi Jim,

 

Here's how I get a product by a product name with this function:

 

 

Public Function GetProduct(ByVal productName As String) As Act.Framework.Opportunities.Product For Each p As Act.Framework.Opportunities.Product In FW.Products.GetProducts(Nothing) If p.Name = productName Then Return p Next Return Nothing End Function

 

Then I use GetProduct("Test").price = 100 if I want to change its price for example. This has worked so far for me.

 

As for deleting, I think you can just do FW.Products.DeleteProducts(GetProduct("Test")) . Hope this helps

 

Hugo Vale
Datastream Custom Solutions
http://www.datastreamcs.com
Avid Listener
Posts: 83
Country: Malaysia

Re: Products.CreateProduct

Hi Hugovale,

 

i encountered errors when i tried to do in c#.

 

public Product GetProduct(string productName) { ActFramework oFram = new ActFramework(); foreach (Product product in oFram.Products.GetProducts(null)) { if (product.Name.Equals(productName)) { return product; } } return null; }

 

 

if (oFram.Products.ProductExists(desp)) { DialogResult result = MessageBox.Show("Existing record found !!!, Do you want replace with new record ?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { //get exiting product Product existingProduct = GetProduct(desp); if (existingProduct != null) { oFram.Products.DeleteProducts(existingProduct);

 

 

I encounetred error messages Error 59 The best overloaded method match for 'Act.Framework.Opportunities.ProductManager.DeleteProducts(Act.Framework.Opportunities.Product[])' has some invalid arguments \

 

Thanks,

Jeff.

Copper Super Contributor
Posts: 59
Country: USA

Re: Products.CreateProduct

Hi Jeff,

 

In your code, the DeleteProducts method expects an array of products and you are passing a single product. You can either use the DeleteProduct Method from the ACT framework, which accepts only one product as the argument, or create a new array of products and add the one you just retrieved using the GetProducts function.

My guess is that DeleteProducts is actually a typo and you actually wanted to use DeleteProduct. 

Hugo Vale
Datastream Custom Solutions
http://www.datastreamcs.com
Avid Listener
Posts: 83
Country: Malaysia

Re: Products.CreateProduct

Hi HugoVale,

 

I had solved it by using below code. I cant find deleteproduct in act framework. it always showed deleteproducts.

Thanks,

Jeff.

if (existingProduct != null) { Product[] products = new Product[1]; products[0] = existingProduct; oFram.Products.DeleteProducts(products); }

 

Copper Super Contributor
Posts: 59
Country: USA

Re: Products.CreateProduct

Hi Jeff,

 

I'm glad you worked out. I was under the impression that there was a DeleteProduct overload that took only one product but apparently there isn't. Anyway, you can go even further with that code and delete the product in the following way: 

 

if (existingProduct != null) { oFram.Products.DeleteProducts(new Product[] { existingProduct }); }

 Hope it helps

 

 

Hugo Vale
Datastream Custom Solutions
http://www.datastreamcs.com
Avid Listener
Posts: 83
Country: Malaysia

Re: Products.CreateProduct

Hi hugovale

 

Thanks for your advice and suggestions.

 

Regards,

Jeff.

Loyal Listener
Posts: 69
Country: United States

Re: Products.CreateProduct

Now with ACT! 2010 we can add custom product fields (which automatically creates a corresponding field in Opp Product table and is very cool)

 

But I can't see how we can edit a custom Product field via the SDK or the ACT! GUI for that matter.  We can edit the custom Opp Product field, but not the custom PRODUCT field.

 

I know that if I use:

 

Dim product As Opportunities.Product = ACTFM.Products.GetProductByItemNumber(itemNumber)

 

I can edit the standard fields like this:  product.price=100

 

But there isn't a Fields Property, even though I can get  

Dim pfd() As Act.Framework.Opportunities.ProductFieldDescriptor

 

So how do I edit custom PRODUCT fields?

 

Thanks.

 

Mike Fortier

Fortier Consulting

mike@fortierconsulting.com