Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
  • Expertise
    • Microsoft Dynamics 365
      • Finance and Operations
      • Customer Relationship Management
      • Customer Engagement
      • Business Central
      • Dynamics 365 Security Services
    • Microsoft Fabric
      • How to build data cortex
    • Cloud Solutions
      • Microsoft Azure
      • DevOps
    • Microsoft Power Platform
    • Security Services
      • Application Security
      • Cloud Security
      • Network Security
      • Red Team Assessment
    • Revenue Cycle Management
    • Salesforce
    • SAP
    • Application Development
  • Products
      Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Microsoft D365FO Connector for ADP Workforce Now
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • BarTender Connector for D365
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • ShipGuru
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • BBPTechnologies
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • LIS365
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • HSBC Connector for Microsoft D365FO
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Paycrypt365 Connector for Microsoft D365FO
  • Industries
      Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Healthcare
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Government
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Insurance
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Banking & Financial Services
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Manufacturing
    • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
    • Retail & E-Commerce
  • Company
    • About Us
    • Case Studies
    • Blogs
    • Careers
  • Contact Us
  • Staffing Solutions

D365 Commerce POS:Add validation before adding an item to cart

Aamir Khan

15July

Problem:

The Customer requires validation to be added before an item is added to a cart in POS. For example, an item must belong to a certain list to be purchased from POS. Or any criteria whatsoever.

Development:

When an item is being added to a cart, one of the requests triggered is SaveCartVersionedDataRequest. We can add a pre-trigger to this request as a Commerce Runtime (CRT) extension. We’d need to implement the IRequestTriggerAsync interface and implement mandatory methods.


public class AddItemToCartValidationTrigger : IRequestTriggerAsync
{

    public IEnumerable SupportedRequestTypes => new[]
    {
        typeof(SaveCartVersionedDataRequest)
    };     
        
    public async Task OnExecuted(Request request, Response response)
    {
        await Task.CompletedTask;
    }
    
    public async Task OnExecuting(Request request)
    {
        boolean criteria = true;
        
        if (criteria) // if some criteria is met, add an item to the cart 
        {
            // do something
        }
        else // reject item to be added to cart
        {
            // throw commerce exception
        }
    }
}
                        

Deployment:

Build your CRT extension and place it in the Retail Server’s extension folder. Drop extension .dll in the RetailServerWebRootbinExt folder and modify CommerceRuntime.Ext the configuration file by adding an extension assembly reference in the composition section of the config file. Restart the Retail Server after adding an extension to it.

To debug locally you can also add this extension .dll in C:Program Files (x86)Microsoft Dynamics 36570Retail Modern POSClientBrokerext folder and add a reference of extension assembly in CommerceRuntime.MPOSOffline.ext config file. Attach it to the IIS process of the Retail Server.

For the Retail SDK build, you’d need to add this CRT extension to CommerceRuntime.ext config in RetailSDK>Assets and customization.settings in RetailSDK>BuildTools.

Tags:
D365 Dynamics 365 AX D365 Commerce Commerce CPOS MPOS Store Commerce
Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner

GuruGroup recognizes the importance of staying up to date through frequent self-inventions. We achieve this by continually attracting the brightest minds in modern digital paradigms and platforms.

  • About Us
  • Products
  • Industries
  • Blogs
  • Contact Us
  • Careers
  • Support
Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner

104 S Woodburn Dr,
Dothan, AL 36305

Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner

Phone: +1 334 446-5235

Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner

Email: info@gurug.com

  • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
  • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
  • Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner Guru Group LLC - Cloud Consulting & IT Solutions Provider | Microsoft & Salesforce Partner
| GuruGroup
  • Terms & Conditions
  • Privacy Policy
  • AI Usage Policy
Ask Guru Group
Hi! 👋 How may I help you today?