Share via


NewPromoCodeDefinition Method (PromoCodeUsageOption, Int32)

Creates a new PromoCodeDefinition object.

Namespace:  Microsoft.CommerceServer.Marketing
Assembly:  Microsoft.CommerceServer.Marketing.CrossTierTypes (in Microsoft.CommerceServer.Marketing.CrossTierTypes.dll)

Syntax

'Declaration
Public Function NewPromoCodeDefinition ( _
    usageOption As PromoCodeUsageOption, _
    usageLimit As Integer _
) As PromoCodeDefinition
'Usage
Dim instance As PromoCodeDefinitionManager
Dim usageOption As PromoCodeUsageOption
Dim usageLimit As Integer
Dim returnValue As PromoCodeDefinition

returnValue = instance.NewPromoCodeDefinition(usageOption, _
    usageLimit)
public PromoCodeDefinition NewPromoCodeDefinition(
    PromoCodeUsageOption usageOption,
    int usageLimit
)
public:
PromoCodeDefinition^ NewPromoCodeDefinition(
    PromoCodeUsageOption usageOption, 
    int usageLimit
)
public function NewPromoCodeDefinition(
    usageOption : PromoCodeUsageOption, 
    usageLimit : int
) : PromoCodeDefinition

Parameters

  • usageLimit
    Type: System..::.Int32
    Specifies the maximum number of times each promotion code created for this definition may be used.

Return Value

Type: Microsoft.CommerceServer.Marketing..::.PromoCodeDefinition
The newly created PromoCodeDefinition object.

Exceptions

Exception Condition
MaximumValueValidationException

One or more numeric property values is set to a value greater than the maximum allowed.

MinimumValueValidationException

One or more numeric property values is set to a value less than the minimum allowed.

PromoCodeUsageValidationException

The PromoCodeUsageOption of the PromoCodeDefinition created is not Public, however the publicPromoCode string is non-empty. Only PublicPromoCodeDefinition objects are allowed to have an associated public promotion code. Or a Public promocode does not have a PublicPromoCode set.

StringLengthValidationException

One or more string property values is set to a disallowed value. The exception contains details of the violation

Remarks

Creates a PromoCodeDefinition object with default values for all properties. The new object does not exist in the database until the Save method is called on the object.

Permissions

See Also

Reference

PromoCodeDefinitionManager Class

PromoCodeDefinitionManager Members

NewPromoCodeDefinition Overload

Microsoft.CommerceServer.Marketing Namespace

PromoCodeUsageOption

UsageLimit