Implementing offline support for D365 MPOS, the details MS didn't document
If you haven’t discovered it on your own these are
undocumented changes you need to do on top of the MS provided steps(See
StoreHours example) to get offline custom entities actions working.
Update SDK namespace
Update the namespace for the C# proxy in RetailSDK_Dev\BuildTools\Microsoft.Dynamics.RetailSdk.Build.settings
to match SDK namespace.
The namespace change will break the SDK compile in many
places. Do a search and replace for “namespace Contoso” in your SDK to your
root namespace as you specified in the settings file.
Specify adapter in MPOS request
In the POS service request you’ll need to make sure that entityType
is specified.
When the MPOS core generates the request URL it will take
the entityType value and append “Manager” to try construct the URL looking
for your offline adaptor manager class. If entityType is missing POS
core will look for your custom entity action in the StoreOperations
adaptor
In the example below the request would be posted back to crt://offline/StoreOperationsManager/UpdatePurchOrdernum
if entityType is missing.
In the current version of the SDK you’ll need to make a
change to the parameter unpacking in the C# proxy project.
The function CommerceRuntimeRequest.prototype.formatParameters
in the Commerce.Core.js will bundle up all parameters to a single object with
the key entity. The C# proxy will compare the parameter names of the input
parameters of your adaptor action with the values passed in the request.
Because there will be only one parameter called entity the parameters will not
be found and the execution will fail.
To fix the problem make the following changes to the Retail
Proxy project.
Add project reference Newtonsoft.Json.Protable. The dll can
be found in the reference folder of the SDK.
Change the constructor of the class CrtUri in
Adapters\CrtUri.cs, add the code between the comments //Unpacking offline
parameters.
Remove the parameter number check in the class AdaptorCaller
and method CallCommerceRuntimeAsync found in Adapters\AdaptorCaller.cs
Comments
Post a Comment