D365 POS extensions - Add extension properties to cart
Within Dynamics 365 for commerce there are often a need to add extension properties to existing objects. Adding extension properties to the cart object is often highly used.
To add an extension property to the cart object in POS we can use the existing SaveExtensionPropertiesOnCartClientRequest/SaveExtensionPropertiesOnCartClientResponse pairs in POS to be able to update the cart.
The following lines of codes can be used to add a simple boolean extension property to the cart object.
var commerceProp = new ProxyEntities.CommercePropertyClass();
commerceProp.Key = "SampleExtProp";
var commercePropValue = new ProxyEntities.CommercePropertyValueClass();
commercePropValue.BooleanValue = true;
commerceProp.Value = commercePropValue;
let extensionProperties: ProxyEntities.CommercePropertyClass[] = [];
extensionProperties.push(commerceProp);
this.context.runtime.executeAsync(new SaveExtensionPropertiesOnCartClientRequest<SaveExtensionPropertiesOnCartClientResponse>(extensionProperties, this.context.logger.getNewCorrelationId())).then((response: ClientEntities.ICancelableDataResult<SaveExtensionPropertiesOnCartClientResponse>) => {
// do something
});
You can read this Microsoft doc for more details.
Comments
Post a Comment