IProduct::CreateVariant

Ee824560.c++_off(en-US,CS.10).gifEe824560.vb_on(en-US,CS.10).gif

Use this method to create a new product variant of the current product. Only product specifc attributes will be set in the new variant.

Definition

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

Parameters

varProductVariantID

[in] A VARIANT that contains the unique ID of the product variant.

ppRSProductVariant

[out, retval] A pointer to a Recordset object used to return the product variant.

Return Values

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

Error Values

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.

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

Constant Value Description
E_CAT_BLANK_VARIANT 0x8898004F A blank value was specified for the VariantID.
E_CAT_CATALOG_DOESNT_SUPPORT_VARIANTS 0x88980032 This catalog does not support product variants. This is determined when the catalog is created and cannot be changed.
E_CAT_INVALID_VARIANTID 0x8898005C The VariantID exceeded 256 characters in length.
E_CAT_INVALIDVALUE_FOR_PROPERTY 0x88980038 An invalid value was specified for one of the product properties.

This error can be due to:

  • One of the values in the recordset does not satisfy the requirements of the minimum value/maximum value attributes set for the properties.

  • An enumeration property has a value that is not defined in its list of legal values.

  • Strings exceed the maximum length defined for the property or are shorter than the minimum length.
E_CAT_INVALIDVALUE_FOR_VARIANTID 0x8898004D An invalid value was specified for the VariantID.

This error can be due to the value of the VariantId being out of range.

E_CAT_NO_VARIANTS_UNDER_PRODUCT 0x88980051 This product does not support variants. Variants cannot be created under a regular product.
E_CAT_PRODUCT_DOESNT_EXIST 0x8898001E This product has been removed from the catalog.
E_CAT_VARIANT_EXISTS 0x88980026 The specified variant already existed.

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.

Remarks

The ppRSProductVariant parameter contains valid data only if the property was accessed successfully.

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

If the catalog created does not support variants, that is strProductVariantID 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 for internal use 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.

The 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 same variant IDs within the same catalog, as long as they are in different product families and the unique Product identifier and the unique Variant identifier are different.

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

See Also

Product Object

IProduct::DeleteVariant

IProduct::SetVariantProperties


All rights reserved.