IProductCatalog3::CreateProduct Method [C++]

Use this method to create a new product within the catalog according to the specified parameters. This method cannot be used with virtual catalogs.

Definition

[C++]

HRESULT IProductCatalog3::CreateProduct(BSTRstrDefinitionName,
 VARIANTvarProductID,
 CURRENCYcyListPrice,
 VARIANTstrParentCategoryName,
 IProduct3**ppProduct);

[Visual Basic]

Function CreateProduct(strDefinitionName As String,
 varProductID As Variant,
 cyListPrice As Currency,
 Optional strParentCategoryName As Variant) As Product

Parameters

  • strDefinitionName[C++]
    [in] A BSTR that contains the name of the product definition for the product.
  • strDefinitionName[Visual Basic]
    A String that contains the name of the product definition for the product.
  • varProductID[C++]
    [in] A VARIANT that contains the unique product ID for the product to be created. The data type must match the property used to uniquely identify products in this catalog.
  • varProductID[Visual Basic]
    A Variant that contains the unique product ID for the product to be created. The data type must match the property used to uniquely identify products in this catalog.
  • cyListPrice[C++]
    [in] A CURRENCY object that contains the list price of the product to be created.
  • cyListPrice[Visual Basic]
    A Currency object that contains the list price of the product to be created.
  • strParentCategoryName[C++]
    [in, optional] A VARIANT that contains the name of the category to be designated as the parent category of the product to be created.
  • strParentCategoryName[Visual Basic]
    A Variant that contains the name of the category to be designated as the parent category of the product to be created.
  • ppProduct[C++]
    [out, retval] A pointer to a Product object used to return the properties of the newly created product.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] If this method completes successfully, it returns the Product object that was created.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_CAT_VC_NOT_A_SUPPLIER_CATALOG

[C++] 0x889800F9

[Visual Basic] &Hx889800F9

Invalid catalog type. This API can only be called on a base catalog.
E_POINTER

[C++] 0x80004003

[Visual Basic] &H80004003

The pointer is invalid..
E_CAT_INVALID_DEFINITION_LENGTH

[C++] 0x889800EA

[Visual Basic] &Hx889800EA

The definition name that you specified is invalid. definition names should be between 1 and 128 characters in length.
E_CAT_INVALID_PARAMETER

[C++] 0x889800B6

[Visual Basic] &H889800B6

The input parameter <parameter number> is invalid.
E_CAT_INVALID_PRODUCTID

[C++] 0x8898005B

[Visual Basic] &H8898005B

The value you specified for the ProductID is blank or else it exceeds the maximum allowed length of 256 characters.
E_CAT_INVALIDVALUE_FOR_PRODUCTID

[C++] 0x8898004E

[Visual Basic] &Hx8898004E

The value you specified for the ProductID is either out of range or does not satisfy the Min/Max condition.
E_CAT_VC_INVALID_PROD_ID_OR_CATEGORY_NAME

[C++] 0x889800FB

[Visual Basic] &Hx889800FB

The value you specified for the ProductID or CategoryName exceeds the maximum allowed length of 348 characters.
E_CAT_INVALID_CATEG_LENGTH

[C++] 0x88980047

[Visual Basic] &Hx88980047

The category name you specified is either blank or exceeds the maximum allowed length of 128 characters or cannot be converted to a string.
E_CAT_VC_INVALID_PROD_ID_OR_CATEGORY_NAME

[C++] 0x889800FB

[Visual Basic] &H889800FB

The value you specified for the ProductID or CategoryName exceeds the maximum allowed length of 348 characters.
E_CAT_DEFINITION_DOESNT_EXIST

[C++] 0x8898000B

[Visual Basic] &H8898000B

The definition you specified does not exist.
E_CAT_CATEGORY_DEFN_FOR_PRODUCT

[C++] 0x8898004A

[Visual Basic] &H8898004A

The definition name that you specified is a category definition. This definition cannot be used to create the product.
E_CAT_INVALID_PRODUCT_DEFINITION

[C++] 0x8898005F

[Visual Basic] &Hx8898005F

The product definition you specified contains a variant property that is being used as the ProductID for this catalog.
E_CAT_PRODUCT_EXISTS

[C++] 0x8898001B

[Visual Basic] &Hx8898001B

The product you specified already exists.
E_CAT_CATEGORY_DOESNT_EXIST

[C++] 0x8898001C

[Visual Basic] &Hx8898001C

The category you specified does not exist.
E_CAT_CHARACTER_NOT_ALLOWED

[C++] 0x8898003D

[Visual Basic] &H8898003D

The catalog name you specified has one of the nine reserved characters " [ ] , ' ( )#. which should not be used.
E_CAT_VC_ERROR_IN_PROPAGATING_BC_CHANGES

[C++] 0x88980101

[Visual Basic] &H88980101

There was an error in propagating the base catalog changes to the dependent virtual catalogs.

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

[C++] The ppProduct parameter contains valid data only if the method was accessed successfully.

A product family is a product that has variants.

The properties of the definition on which a new product is based will determine whether the product being created is a single product or a product family. If the definition used to create the product has variant properties, the newly created product will be a product family.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

SET oMyNewProduct = myProductCatalog.CreateProduct("BasicProduct", "SKU3004", cyListPrice, "Apparel")

See Also

[C++]ProductCatalog Object

[Visual Basic]ProductCatalog Object

[C++]IProductCatalog3::DeleteProduct

[Visual Basic]ProductCatalog.DeleteProduct

[C++]IProductCatalog3::GetProduct

[Visual Basic]ProductCatalog.GetProduct

Copyright © 2005 Microsoft Corporation.
All rights reserved.