Work with the Promotions Entity Views and Actions API (C#)
External systems can integrate Sitecore XC promotions-related operation and exchange promotions-related data with other systems using the Sitecore XC Promotions Entity Views and Actions API.
You must include Commerce Engine operations and commands within a container call (using C#) as shown in this example.
To execute any operation in the Sitecore Experience Commerce (XC) system, the calling system must first obtain a valid bearer authorization token for the Sitecore Identity Server.
The Promotions View and Actions API supports actions to Add, Get, Edit and Manage Associated Catalogs for promotions books.
The Views and Actions API is an authoring API designed to service a business user interface and is not optimized for integration scenario.
You should consider the following when using the Views and Actions API for your commerce integration:
-
The Views and Actions API can only process one Commerce entity at the time and does not support batch processing.
-
The Views and Actions API carries more overhead than the Commerce web service API. A call to the Views and Action API is typically a 3-step process that requires getting the action's view, modifying the view's properties with updated values, and then executing the action.
Add a promotion book (C#)
You can create a new promotion book programmatically using an API request. Once a promotion book exists, you cannot change its name. You cannot delete a promotion book.
To add a promotion book using C#:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView(string.Empty, "Details", "AddPromotionBook", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's properties by specifying a
Name, aDisplayName,and aDescription, for example:RequestResponsevar nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Name")); nameProperty.Value = "MyPromotionBook"; var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); displayNameProperty.Value = "Book Display Name"; var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); descriptionProperty.Value = "Book Description"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Get views from a promotion book (C#)
You can use the Views API to retrieve different views of a promotion book.
The Views API uses Composite EntityViews. You can request master views, but you can also request child views.
Retrieve a promotion's book master view
To retrieve a promotion's book master view:
DataServiceActionQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Master", string.Empty, string.Empty);
EntityView view = Proxy.GetValue(query);
Retrieve a promotion book's details view
To retrieve a promotion book's details view:
query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", string.Empty, string.Empty);
view = Proxy.GetValue(query);
Retrieve a promotion book's associated catalogs view
To retrieve a promotion book's associated catalogs view:
query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "PromotionBookCatalogs", string.Empty, string.Empty);
view = Proxy.GetValue(query);
Retrieve a promotion book's promotions view
To retrieve a promotion book's view:
query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Promotions", string.Empty, string.Empty);
view = Proxy.GetValue(query);
Edit a promotion book (C#)
You can change the values of the DisplayName and Description properties of an existing promotion book. You cannot change it's internal name (the value of the Name property). If the request does not specify values, then existing values remain unchanged.
To edit the details of a promotion book:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", "EditPromotionBook", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's properties, for example, by specifying a
DisplayNameor aDescription, or both, as show in the following example:RequestResponsevar displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); displayNameProperty.Value = "Edited Book Display Name"; var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); CommerceCommand command = Proxy.DoCommand(container.DoAction(view));descriptionProperty.Value = "Edited Book Description"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Associate a catalog with a promotion book (C#)
You associate a catalog to a promotion so that promotions defined in the book can apply to the catalog items. You can associate a promotion book to multiple catalogs, but a catalog can only be associated to one promotion book.
To associate a catalog with a promotion book:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", string.Empty, "DisassociateCatalog", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the views properties, for example, to specify the catalog you want to associate, for example:
RequestResponseview.ItemId = "MyCatalog"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add a promotion (C#)
You create a promotion within a promotion book. Within the promotion book, the name of the promotion must be unique. You cannot change the name of a promotion.
To add a promotion:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-PromotionBook-{bookFriendlyId}", "Details", "AddPromotion", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's property to specify the promotion's details, for example:
RequestResponsevar nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Name")); nameProperty.Value = "MyPromotion"; var displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); displayNameProperty.Value = "Promotion Display Name"; var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); descriptionProperty.Value = "Promotion Description"; var displayTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayText")); displayTextProperty.Value = "Promotion Text"; var displayCartTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayCartText")); displayCartTextProperty.Value = "Promotion Cart Text"; var validFromProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidFrom")); validFromProperty.Value = DateTimeOffset.UtcNow.ToString(CultureInfo.InvariantCulture); var validToProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidTo")); validToProperty.Value = DateTimeOffset.UtcNow.AddDays(30).ToString(CultureInfo.InvariantCulture); var isExclusiveProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("IsExclusive")); isExclusiveProperty.Value = "true"; -
Execute the action
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The request returns the promotion's friendly ID as part of the
PromotionAddedmodel, for example:RequestResponsePromotionAdded promotionAddedModel = command.Models.OfType<PromotionAdded>().FirstOrDefault(); string promotionFriendlyId = promotionAddedModel?.PromotionFriendlyId;
Get a promotion's views (C#)
You can retrieve different views of a promotion using the Views API.
To retrieve a promotion's master view:
DataServiceActionQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Master", string.Empty, string.Empty);
EntityView view = Proxy.GetValue(query);To retrieve a promotion's details view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", string.Empty, string.Empty);
view = Proxy.GetValue(query);To retrieve a promotion's qualifications view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Qualifications", string.Empty, string.Empty);
view = Proxy.GetValue(query);To retrieve the promotion's benefits view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Items", string.Empty, string.Empty);
view = Proxy.GetValue(query);To retrieve the promotion's items view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Items", string.Empty, string.Empty);
view = Proxy.GetValue(query);To retrieve the promotion's public coupon's view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "PublicCoupons", string.Empty, string.Empty);
view = Proxy.GetValue(query);
view = Proxy.GetValue(query);To retrieve the promotion's private coupon's view:
query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "PrivateCoupons", string.Empty, string.Empty);
view = Proxy.GetValue(query);Edit a promotion (C#)
You can change the values of an existing promotion's properties.
You can only make change a to a promotion when it is in the Draft state.
To edit a promotion:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", "EditPriceCard", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's properties as required, for example:
NoteIf no values are provided for
DisplayNameand/orDescription, current values remain unchanged. The rest of the properties are required. (A property is required whenIsRequiredis set to"true".RequestResponsevar displayNameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); displayNameProperty.Value = "Edited Promotion Display Name"; var descriptionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); descriptionProperty.Value = "Edited Promotion Description"; var displayTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayText")); displayTextProperty.Value = "Edited Promotion Text"; var displayCartTextProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayCartText")); displayCartTextProperty.Value = "Edited Promotion Cart Text"; var validFromProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidFrom")); validFromProperty.Value = DateTimeOffset.UtcNow.AddDays(3).ToString(CultureInfo.InvariantCulture); var validToProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ValidTo")); validToProperty.Value = DateTimeOffset.UtcNow.AddDays(33).ToString(CultureInfo.InvariantCulture); var isExclusiveProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("IsExclusive")); isExclusiveProperty.Value = "false"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add a qualification (C#)
Qualifications are the conditions you set on a promotion and that need to be met for the promotion benefits to be applied to a shopper's order. Sitecore XC provides multiple qualifications that can be applied to a promotion.
To add a qualification to a promotion:
-
Get the entity view, for example, to add the Cart Has [count] items? qualification to the promotion:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "QualificationDetails", "SelectQualification", string.Empty)); var conditionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Condition")); var availableConditionsPolicy = conditionProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault(); conditionProperties.Value = availableConditionsPolicy?.List.FirstOrDefault(o => o.Name.Equals("CartHasItemsCountCondition")).Name; CommerceCommand command = Proxy.DoCommand(container.DoAction(view)); -
Set the qualification value. In the following example, the item count for the Cart Has [count] items? is set to 3:
RequestResponseview = command.Models.OfType<EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name)); var countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count")); countProperty.Value = "3"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The qualification id is returned in the
QualificationAddedmodel, for example:RequestResponsevar qualificationId = addAction.Models.OfType<QualificationAdded>().FirstOrDefault()?.QualificationId;
Edit a qualification (C#)
You can make changes to an existing qualification using the Views/Actions API.
To edit a qualification, for example, to edit the Cart Has [count] Items? qualification, by setting the count property to 5:
-
Get the entity view:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "QualificationDetails", "EditQualification", qualificationId)); -
Edit the qualification's property value as required, for example, to change the item count of the Cart Has [count] Items? qualification to 5:
RequestResponsevar countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count")); countProperty.Value = "5"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add a benefit (C#)
Benefits are the possible discounts that apply to a promotion. The benefits are applied to a customer's order when the qualification conditions for the promotion are met. Sitecore XC predefines benefits that you can applied to one promotion. You can add multiple benefits to one promotion.
To add a benefit to a promotion:
-
Get the entity view, for example, to apply the Get Cart Subtotal [specific] Amount Off benefit to a promotion:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "BenefitDetails", "SelectBenefit", string.Empty)); var actionProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Action")); var availableActionsPolicy = actionProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault(); actionProperty.Value = availableActionsPolicy?.List.FirstOrDefault(o => o.Name.Equals("CartSubtotalAmountOffAction")).Name; CommerceCommand command = Proxy.DoCommand(container.DoAction(view)); -
Set the benefit value property. For example, the following sample sets the AmountOff value to 50.
RequestResponseview = command.Models.OfType<EntityView>().FirstOrDefault(v => v.Name.Equals(view.Name)); var amountProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("AmountOff")); amountProperty.Value = "50"; command = Proxy.DoCommand(container.DoAction(view));"CartSubtotalAmountOffAction -
Execute the action:
RequestResponsecommand = Proxy.DoCommand(container.DoAction(view));The benefit id is returned using the
BenefitAddedmodel, for example:RequestResponsevar benefitId = addAction.Models.OfType<BenefitAdded>().FirstOrDefault()?.BenefitId;
Edit a benefit (C#)
You can make changes to an existing benefit by changing its properties value.
To edit a benefit, for example to change the value of the discounted amount in the Get Cart Subtotal [specific] Amount Off benefit:
-
Get the entity view:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "BenefitDetails", "EditBenefit", benefitId)); -
Modify the value of the
"AmountOff"property, for example, to 20:RequestResponsevar amountProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("AmountOff")); amountProperty.Value = "20"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Delete a benefit (C#)
You can delete a benefit from a promotion.
To delete a benefit:
-
Get the entity view and include, in the query, the friendly ID of the promotion and the benefit ID that you want to delete, for example:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, string.Empty, "DeleteBenefit", benefitId)); -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add an item to a promotion (C#)
Need to confirm the purpose statement - not sure it jives with the code sample in step 2You add an item (for example, a sellable item or a variant of item) to a promotion so that the promotion applies to individual items (as opposed to apply the promotion at the catalog level).
You can only change a promotion when it is in the Draft state. You cannot modify a promotion that is in the approved state.
To add an item to a promotion:
-
Get the entity view:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "ItemDetails", "AddItem", string.Empty)); -
Modify the view's properties, for example to add a not excluded property to a promotion:
RequestResponsevar catalogProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Catalog")); var availableCatalogsPolicy = catalogProperty.Policies.OfType<AvailableSelectionsPolicy>().FirstOrDefault(); catalogProperty.Value = availableCatalogsPolicy?.List.FirstOrDefault(o => o.Name.Equals("MyCatalog"))?.Name; var itemIDProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("ItemId")); itemIDProperty.Value = "MyProduct|MyCatalog|MyVariant"; var excludedProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Excluded")); excludedProperty.Value = "false"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The item id is returned using the
PromotionItemAddedmodel, for example:RequestResponsestring itemId = command.Models.OfType<PromotionItemAdded>().FirstOrDefault()?.PromotionItemId;
Removing an item from a promotion (C#)
You can remove an item from a promotion using the Views and Actions API.
To remove an item from a promotion:
-
Get the entity view, and include, in the query, the friendly ID of the promotion and the item ID you want to remove, for example:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, string.Empty, "RemoveItem", itemId)); -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add a public coupon to a promotion (C#)
A public coupon is a string of text that can be used multiple times.
To add a public coupon to a promotion:
-
Get the entity view:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "PublicCoupons", "AddPublicCoupon", string.Empty)); -
Modify the view's properties to specify the
codeProperty.Value, for example:RequestResponsevar codeProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Code")); codeProperty.Value = "MyPublicCoupon_ABC123"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Add a private coupon to a promotion (C#)
A private coupon is a discount code that is assigned to a single customer. You can specify how many private coupons you want to create
To add a private coupon to a promotion:
-
Get the entity view, for example:
RequestResponsestring promotionId = $"Entity-Promotion-{promotionFriendlyId}"; EntityView view = Proxy.GetValue(container.GetEntityView(promotionId, "CouponDetails", "AddPrivateCoupon", string.Empty)); -
Modify the view's properties to specify coupon allocations details. The following is a query to create 20 possible allocations.
RequestResponsevar prefixProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Prefix")); prefixProperty.Value = "before_"; var suffixProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Suffix")); suffixProperty.Value = "_after"; var totalProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Total")); totalProperty.Value = "20"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The coupon friendly id is returned using the
PrivateCouponGroupAddedmodel, for exampleRequestResponsestring privateCouponId = command.Models.OfType<PrivateCouponGroupAdded>().FirstOrDefault()?.GroupFriendlyId;
Allocate private coupons (C#)
You can use the Promotions Views and Actions API to allocate generated private coupons to a specific promotional campaign.
To allocate private coupons:
-
Get the entity view for the action:
RequestResponsestring groupId = $"Entity-PrivateCouponGroup--{privateCouponId}"; EntityView view = Proxy.GetValue(container.GetEntityView(groupId, "AllocationDetails", "NewAllocation", string.Empty)); -
Modify the view's properties, for example, to allocate 10 coupons:
RequestResponsevar countProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Count")); countProperty.Value = "10"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The list of the allocated coupons code is returned using the
PrivateCouponListmodel.
Duplicate a promotion (C#)
You can duplicate an existing promotion, using the Views and Actions API, to create a new promotion within the same promotion book. The new promotion is in the Draft status, which allows you to edit it.
To duplicate a promotion:
-
Get the entity view for the action:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "Details", "DuplicatePromotion", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's properties, for example:
RequestResponsevar nameProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("PromotionDuplicateName")); nameProperty.Value = "MyDuplicatePromotion"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Changing a promotion status
Promotions are subject to the promotion approval process. During the approval flow, promotion status can transition as follows:
-
From Draft to ReadyForApproval (see Submit a promotion for approval (C#))
-
From ReadyForApproval to Draft (see Reject a promotion (C#))
-
From ReadyForApproval to Approved (see Approve a promotion (C#))
-
From Approved to Disabled (see Disable an approved promotion)
Submit a promotion for approval (C#)
You can submit a draft promotion for approval.
To request approval for a promotion:
-
Get the view for the action:
RequestResponse// requesting approval DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RequestPromotionApproval", snapshotId); EntityView view = Proxy.GetValue(query); -
Modify the view's properties to request approval:
RequestResponsevar commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment")); commentProperty.Value = "Requesting approval"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The status of the promotion changes from Draft to ReadyForApproval.
Reject a promotion (C#)
You can reject a promotion when its status is ReadyForApproval.
To reject a promotion and set it back to the draft status:
-
Get the view for the action:
RequestResponse// rejecting DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RejectPromotion", snapshotId); EntityView view = Proxy.GetValue(query); -
Modify the view's properties to reject the approval request:
RequestResponsevar commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment")); commentProperty.Value = "Rejecting approval"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The promotion returns to the Draft status.
Approve a promotion (C#)
You can approve a promotion when its status is ReadyForApproval.
To approve a promotion:
-
Get the view for the action:
RequestResponse// approving DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "ApprovePromotion", snapshotId); EntityView view = Proxy.GetValue(query); -
Modify the view's properties to approve the promotion:
RequestResponsevar commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment")); commentProperty.Value = "Approving"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));The promotion's status changes to Approved.
Disable an approved promotion
You can disable an approved promotion. When you disable a promotion, it remains approved but it is no longer active. You cannot reactivate a disabled promotion.
To disable an approved promotion
-
Get the view for the action:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", "SetPromotionApprovalStatus", "RetractPromotion", snapshotId); EntityView view = Proxy.GetValue(query); -
Modify the view's properties to disable the active promotion:
RequestResponsevar commentProperty = view.Properties.FirstOrDefault(p => p.Name.Equals("Comment")); commentProperty.Value = "Retracting the promotion"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Delete a promotion (C#)
You can delete a promotion when it is the Draft status.
To delete a promotion:
-
Get the entity view for the action, for example:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Promotion-{promotionFriendlyId}", string.Empty, "DeletePromotion", string.Empty); EntityView view = Proxy.GetValue(query); -
Modify the view's properties to specify the
promotionFriendlyId, for example:RequestResponseview.ItemId = $"Entity-Promotion-{promotionFriendlyId}"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));