Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This method is used to generate promo codes for a discount. The discount must already be associated with a PromoCodeDefinition.
Namespace: Microsoft.CommerceServer.Marketing.WebService
Assembly: Microsoft.CommerceServer.Marketing.DataManagement (in Microsoft.CommerceServer.Marketing.DataManagement.dll)
Syntax
'Declaration
<WebMethodAttribute> _
Public Overridable Function GenerateRandomPromoCodes ( _
promoCodeDefinitionId As Integer, _
batchName As String, _
numberOfCodes As Integer, _
generationParameters As RandomGenerationParameters _
) As Guid
'Usage
Dim instance As MarketingWebService
Dim promoCodeDefinitionId As Integer
Dim batchName As String
Dim numberOfCodes As Integer
Dim generationParameters As RandomGenerationParameters
Dim returnValue As Guid
returnValue = instance.GenerateRandomPromoCodes(promoCodeDefinitionId, _
batchName, numberOfCodes, generationParameters)
[WebMethodAttribute]
public virtual Guid GenerateRandomPromoCodes(
int promoCodeDefinitionId,
string batchName,
int numberOfCodes,
RandomGenerationParameters generationParameters
)
[WebMethodAttribute]
public:
virtual Guid GenerateRandomPromoCodes(
int promoCodeDefinitionId,
String^ batchName,
int numberOfCodes,
RandomGenerationParameters^ generationParameters
)
public function GenerateRandomPromoCodes(
promoCodeDefinitionId : int,
batchName : String,
numberOfCodes : int,
generationParameters : RandomGenerationParameters
) : Guid
Parameters
- promoCodeDefinitionId
Type: System..::.Int32
The identifier of the PromoCodeDefinition for which promo codes should be generated.
- batchName
Type: System..::.String
A client-created batch name. This must be unique. The client can use this batch name later to request the status of a promo code generation task.
- numberOfCodes
Type: System..::.Int32
The number of codes to generate for the discount.
- generationParameters
Type: Microsoft.CommerceServer.Marketing..::.RandomGenerationParameters
A parameter that specifies the other options that are to be used for the generation.
Return Value
Type: System..::.Guid
The identifier of the promo code generation batch that will be generating the promo codes.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The promoCodeDefinitionId provided is not a valid ID value. |
| 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. |
| InvalidCatalogOperationException | Promo codes cannot be generated for a Public or Restricted definition. |
| 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. |
| EntityDoesNotExistException | No promo code definition exists with the promoCodeDefinitionId provided. |
| DuplicateEntityNameException | A batch record already exists with the provided name. |
| ServerFaultException | An unexpected error occurred on the server. |
Remarks
This method is used to generate promo codes for a discount. The discount must already be associated with a PromoCodeDefinition.
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.