Jaa


GenerateRandomCodes Method

Generates promotion codes for the specified PromoCodeDefinition.

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

Syntax

'Declaration
Public Function GenerateRandomCodes ( _
    promoCodeDefinitionId As Integer, _
    batchName As String, _
    numberOfCodes As Integer, _
    generationParameters As RandomGenerationParameters _
) As Guid
'Usage
Dim instance As PromoCodeDefinitionManager
Dim promoCodeDefinitionId As Integer
Dim batchName As String
Dim numberOfCodes As Integer
Dim generationParameters As RandomGenerationParameters
Dim returnValue As Guid

returnValue = instance.GenerateRandomCodes(promoCodeDefinitionId, _
    batchName, numberOfCodes, generationParameters)
public Guid GenerateRandomCodes(
    int promoCodeDefinitionId,
    string batchName,
    int numberOfCodes,
    RandomGenerationParameters generationParameters
)
public:
Guid GenerateRandomCodes(
    int promoCodeDefinitionId, 
    String^ batchName, 
    int numberOfCodes, 
    RandomGenerationParameters^ generationParameters
)
public function GenerateRandomCodes(
    promoCodeDefinitionId : int, 
    batchName : String, 
    numberOfCodes : int, 
    generationParameters : RandomGenerationParameters
) : Guid

Parameters

  • batchName
    Type: System..::.String
    The name of a new batch of promocodes. May not be nullNothingnullptra null reference (Nothing in Visual Basic).
  • numberOfCodes
    Type: System..::.Int32
    The number of codes to generate for this batch.

Return Value

Type: System..::.Guid
The Id of the generation batch that will be used to generate the promotion codes.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The promoCodeDefinitionId argument value is less than or equal to zero.

EntityDoesNotExistException

No promo code definition exists with the Id provided.

InvalidOperationException

Promo codes cannot be generated for a Public or Restricted definition.

ImportInProgressException

The user already has another import or generation job going for the specified definition.

ArgumentNullException

One of the provided arguments (either batchName or generationParameters) is nullNothingnullptra null reference (Nothing in Visual Basic).

ArgumentException

The numberOfCodes argument is less than or equal to zero.

NotAuthorizedException

The user is not authorized to perform this operation.

MaximumValueValidationException

The total length of the codes to be generated is greater than the maximum allowed length.

PropertyNullValidationException

The batchName provided is nullNothingnullptra null reference (Nothing in Visual Basic).

StringLengthValidationException

The batchName provided is an empty string or longer than the maximum allowed batch name length.

DuplicateEntityNameException

A batch record already exists with the provided name.

ServerFaultException

An unexpected error occurred on the server.

Remarks

The promotion codes generated by this method contain randomly generated characters selected from the alphabet specified by the s_PromoCodeRandomCharacterSet site resource constant (contained in the Marketing resource). There may be a site-imposed limit on the number of codes that can be generated. This restriction is specified by the site resource i_MaxPromoCodeBatchSize. If you request to generate more codes than the site allows, the batch will asynchronously fail. The error will be contained in the event log.

Permissions

See Also

Reference

PromoCodeDefinitionManager Class

PromoCodeDefinitionManager Members

Microsoft.CommerceServer.Marketing Namespace

RandomGenerationParameters