Share via


NewPromoCodeDefinition Method (PromoCodeUsageOption, Int32, String)

Creates a new PromoCodeDefinition object with the specified Promotion Code.

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, _
    publicPromoCode As String _
) As PromoCodeDefinition
'Usage
Dim instance As PromoCodeDefinitionManager
Dim usageOption As PromoCodeUsageOption
Dim usageLimit As Integer
Dim publicPromoCode As String
Dim returnValue As PromoCodeDefinition

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

Parameters

  • usageLimit
    Type: System..::.Int32
    A UsageLimit that specifies the maximum number of times each PromoCode created for this definition may be used.
  • publicPromoCode
    Type: System..::.String
    The public code associated with the promotion code definition, there is one code associated with each Public promotion code definition, for other types of promotion codes, there will be many codes associated, therefore the parameter does not take into effect.

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 and the specified Promotion Code. 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

PublicPromoCode