IProduct3::CreateVariant Method [C++]

Use this method to create a new product variant of the current product. Only product-specific attributes will be set in the new variant. This method applies only to base catalogs.

Definition

[C++]

HRESULT IProduct3::CreateVariant(VARIANTvarProductVariantID,
  _Recordset**ppRSProductVariant);

[Visual Basic]

Function CreateVariant(varProductVariantID As Variant) As Recordset

Parameters

  • varProductVariantID[C++]
    [in] A VARIANT that contains the unique ID of the product variant.
  • varProductVariantID[Visual Basic]
    A Variant that contains the unique ID of the product variant.
  • ppRSProductVariant[C++]
    [out, retval] A pointer to a Recordset object used to return the product variant.

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 a recordset that contains the properties for the variant.

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 describes the custom COM errors this method can return.

Constant Value Description
E_CAT_VC_NOT_A_SUPPLIER_CATALOG

[C++] 0x889800F9

[Visual Basic] &H889800F9

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

[C++] 0x88980032

[Visual Basic] &H88980032

This catalog does not support variants. In order to support variants catalog has to be created with variant identifier.
E_CAT_NO_VARIANTS_UNDER_PRODUCT

[C++] 0x88980051

[Visual Basic] &H88980051

You cannot create a variant under a regular product. Variants can be created under product families only.
E_CAT_INVALID_PARAMETER

[C++] 0x889800B6

[Visual Basic] &H889800B6

The input parameter <parameter number> is invalid.
E_CAT_INVALID_VARIANTID

[C++] 0x8898005C

[Visual Basic] &H8898005C

The value you specified for the VariantID exceeds the maximum allowed length of 256 characters.
E_CAT_INVALIDVALUE_FOR_VARIANTID

[C++] 0x8898004D

[Visual Basic] &H8898004D

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

[C++] 0x8898004F

[Visual Basic] &H8898004F

You have specified a blank value for the VariantID. A variant cannot be created with a blank value.
E_CAT_VC_INVALID_VARIANT_ID

[C++] 0x889800FC

[Visual Basic] &H889800FC

The value you specified for the VariantID exceeds the maximum allowed length of 348 characters.
E_CAT_VARIANT_EXISTS

[C++] 0x88980026

[Visual Basic] &H88980026

The product variant you specified already exists.
E_CAT_PRODUCT_DOESNT_EXIST

[C++] 0x8898001E

[Visual Basic] &H8898001E

The product you specified doesn't exist.

[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 ppRSProductVariant parameter contains valid data only if the method was accessed successfully.

The value and type of the varProductVariantID parameter must be valid for the product property specified as the unique ID for product variants. This property is specified when a catalog is created, as the strProductVariantID parameter to the ICatalogManager3::CreateCatalog method.

[Visual Basic]

The returned recordset contains valid data only if the method was accessed successfully.

The value and type of the varProductVariantID parameter must be valid for the product property specified as the unique ID for product variants. This property is specified when a catalog is created, as the strProductVariantID parameter to the CatalogManager.CreateCatalog method.

If the catalog created does not support variants, that is the strProductVariantID parameter was not specified on catalog creation, an error is returned.

Upon successful completion, the method returns an ActiveX Data Object (ADO) recordset that contains fields for all the properties defined for the new product variant and an integer field named OID. The OID field is used internally by the Product Catalog System and should not be updated. The returned recordset is updateable, but disconnected. In order to modify the variant properties, pass this recordset to the SetVariantProperties method.

Product variants inherit the properties that are present in the product definition. Values for non variant-specific product properties are propagated from the Product object down to the variants, but values for variant-specific properties must be explicitly set for each variant.

The variant ID value should be unique within the product family. There can be two product variants with the same variant IDs within the same catalog, as long as they are in different product families.

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

[Visual Basic]

Example

Set rsVariantProps = myProduct.CreateVariant("SKU4005XLA")

See Also

[C++]Product Object

[Visual Basic]Product Object

[C++]IProduct3::DeleteVariant

[Visual Basic]Product.DeleteVariant

[C++]IProduct3::SetVariantProperties

[Visual Basic]Product.SetVariantProperties

Copyright © 2005 Microsoft Corporation.
All rights reserved.