RE: Change unit of measure after SaveAttributeCartLineRequest on POS D365
Hi,
Are you sure 'change unit of measure' is always executed after 'add attribute' - and they are never running in parallel? It looks like 2 functions you are using return Promise, but 'change unit of measure' does not wait, while 'add attribute' is complete - this way cart versions can be messed and 'Cart version' error will be displayed.
You can use RefreshCartClientRequest to refresh cart after adding an attribute, but this will not fix the issue 100%, if you do not execute all Promise functions in correct sequence.
Correct async execution could look like (pseudo code sample)
return this.addAttrubute()
.then((result: bool) => {
if (result){ //only change unit of measure, if add attribute finished successfully
return this.changeUnitOfmeasure()
.then((result: bool) => {
//show error to user that UOM change failed
}
}
else {
//show error to user, that attribute was not added
}
})