Adding a item to the AX R3 Online Store gives the error message “We cannot Process your request at this time. Please try again later. “

As my first official blog posting I thought I’d share an interesting issue I encountered.  We couldn’t add any items in AX 2012 R3 Online Store to our Shopping Cart as an Anonymous Customer.  When we tried to add any item we would encounter the error message, “We cannot Process your request at this time.  Please try again later. “



Unfortunately this is a pretty vague error message and doesn’t really explain why we can’t add an  item.   To help narrow this down further our best place to start is the SharePoint Log files. In a default SharePoint Server  install, the log files are found in:   C:\Program Files\Common Files\Microsoft shared\Web Server Extensions\15\LOGS   If you have installed SharePoint elsewhere please check with your SP Admin for the log location.    Since the AX Online Store is set to log to Error Level by default we should be able to see any error messages in the logs that we saw on the webpage.    By simply searching the SharePoint Log files for the error message, “We cannot process”  I was able to find the below Call Stacks.



11/17/2014  08:21:23.83         w3wp.exe  (0x1CEC)    0x2538        Dynamics AX Retail 1   General Logging 1            1        Unexpected        Exception id: ,

 Error message: We cannot process your request at this time. Please try again later.System.NullReferenceException: Object reference not set to an instance of an object.     at
Microsoft.Dynamics.Commerce.Runtime.Workflow.CartWorkflowHelper.AddCustomerAffiliationsToCart(RequestContext context, Cart newCart)     at
Microsoft.Dynamics.Commerce.Runtime.Workflow.CartWorkflowHelper.PerformSaveCartOperations(RequestContext context, SaveCartRequest request)     at
Microsoft.Dynamics.Commerce.Runtime.Workflow.CreateOrUpdateCartRequestHandler.Process(SaveCartRequest request)     at
Microsoft.Dynamics.Commerce.Runtime.Workflow.WorkflowRequestHandler`2.Execute(RequestContext context)     at
Microsoft.Dynamics.Commerce.Runtime.Workflow.Composition.PipelineRequestHandler.Execute(RequestCo…        bd0bcd9c-fe56-60d5-0f65-14c790caa354


 The error message in the above call stack is still pretty vague. However if we look at the Call stack itself we get a few more clue as to where the problem may be coming from.  The error message, “System.NullReferenceException: Object reference not set to an instance of an object”  typically tells us that either we received a Null value, or a method in code wasn’t properly initialized before we called it.  Unfortunately this again is a very common error and doesn’t tell us what wasn’t set.   However the line before it calling  “Microsoft.Dynamics.Commerce.Runtime.Workflow.CartWorkflowHelper.AddCustomerAffiliationsToCart”    Gives a much better clue,  this line indicates that we were trying to set add a Customer Affiliation (Customer specific discounts, like Employee, Military, Frequent Shopper) to our Shopping Cart  via the Commerce Run Time Service.   


Since in this scenario we are trying to buy something as an anonymous customer we shouldn’t  have a customer id associated to our transaction. My obvious question becomes, “Why are we looking for Affiliations for a Customer ID that we didn’t supply and where did this Customer ID come from?”      The answer for this is actually quite simple,  whenever we add an item to the Shopping Cart we query the CRT.customerView  table for the Customer Record.  Based on the results of this view we then get the respective affiliations for that customer.  In the case of an Anonymous Customer we actually use the  Default Customer specified in the  AX Online Store’s form. 


 To figure out what Customer ID’s are available at the Channel Database level, I ran the below query.


 Select * from crt.CustomersView      


 The result was no records returned!




Comparing the Results of the View with our Call stack we can now see why the code was giving us an “Object Reference Error” as no customers are showing in the view.  At a minimum we should always get our Default Customer in this view.  To figure out why our default Customer wasn’t showing in the view,  I first needed to know how this view was pulling data.   To do this  I opened SQL Server Management Studio and locate the CRT.CustomersView in the Online Store Database. By simply right clicking this view and selecting > Script to New Query Window.   We can see that the view is mostly comprised of a join between the AX.CustTable , AX.DirPartyTable and the AX.RetailCustTable.  Unfortunately in AX HQ these tables aren’t so easily linked together.  Instead the CustTable is linked back to the DirParty table via the AddressBook tables.  Since a Default Customer is a required field  in the AX Online Store form and our view is based on Address Books, we know that the problem is either coming from the Address Book for the Online store, or the Customers listed in the Store’s Address Book.




  Since my Channel Database doesn’t show any Customers belong to the Store’s Address book.  My next approach is to see what we have  listed in AX.  Since I already know the table relationship for AX, and what the Store’s Customer Address Book is set to.  We can run a quick SQL query to see what Customers in AX should be tied to this Address Book. Running the below query against the AX Database (Remember to change the where clause to match the address book listed for your Online Store)


Select * from DIRADDRESSBOOK b


join custtable c on p.PARTY = c.PARTY

where = ‘USRTCentrl’


The result was no records returned!



 At this point the issue becomes self-explanatory we don’t have any customers, including our Default Customer, in the Store’s Address Book. 
To correct this we simply need to add out Default Customer for the Online Store to the Online Channel’s Customer’s Address Book. 


To Correct this:

  1.  Log into an AX Client > Go to Retail  > Common > Retail Channels > Online Stores > Edit your Channel Database (yes edit it)
  2. Right Click your Default  customer Field > Select View Details
  3. Edit your Customer Record
  4. In the General Fast Tab >  Assign your Retail Store’s Address to the Address Books field.
  5. Save your Changes.
  6. Republish the Online Store
  7. Finally run the 1010  (Customers) and 1070 (channel configuration)  jobs for your Online Store Data Group




Unfortunately adding the Default Customer to the Online Store’s Address Book is not a requirement when setting up the Online Store.   It’s very easy to overlook this simple set up issue since it’s not required.    Hopefully some of the meth ology I used above to troubleshoot this issue will help you in your own Online Store endeavors.