Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Unanswered

Edit Serial number in cart line

Posted on by 375

Hello every one,

i need to update serial number in cart line , so i used  below 

public class SavecartVersionDataTrigger : IRequestTriggerAsync
{
public IEnumerable<Type> SupportedRequestTypes =>
new[] { typeof(SaveCartVersionedDataRequest) };

public async Task OnExecuting(Request request)
{
await Task.CompletedTask;
}
public async Task OnExecuted(Request request, Response response)
{
var SaveCart = request as SaveCartVersionedDataRequest;
var cartLines = SaveCart.SalesTransaction;
if (cartLines != null)
{
foreach (var cartLine in cartLines.SalesLines)
{
var BarcodInfoReqest = new GetBarcodeInfoRequest(request.RequestContext.GetDeviceConfiguration().TerminalId, cartLine.ItemId);
var BarcodeInfo = request.RequestContext.ExecuteAsync<GetBarcodeInfoResponse>(BarcodInfoReqest);

var updateInforequest = new UpdateItemBarcodeInfoRequest(BarcodeInfo.Result.BarcodeInfo.FirstOrDefault().IDString, cartLine.LineNumber, cartLines.Id);
var updateInfoResponse = request.RequestContext.ExecuteAsync<GetBarcodeInfoResponse>(updateInforequest);
if (cartLine.GetProperty("Updated") != null)
continue;

if (string.IsNullOrEmpty(cartLine.SerialNumber))
{
cartLine.SerialNumber = BarcodeInfo.Result.BarcodeInfo.FirstOrDefault().SerialIDString;
cartLine.BatchId = BarcodeInfo.Result.BarcodeInfo.FirstOrDefault().BatchIDString;

cartLine.Comment = BarcodeInfo.Result.BarcodeInfo.FirstOrDefault().BatchIDString;

}
cartLine.SetProperty("Updated", Convert.ToInt32(true));
}
}

await Task.CompletedTask;
}
}
}

it's successfully add the serial number to the cart but  with the below error 

pastedimage1646827111442v1.png

so any idea how can solve this .

  • Ramune Profile Picture
    Ramune on at
    RE: Edit Serial number in cart line

    Hi Ahmed,

    As this question is related to the extension, I will leave it for the community to answer. Let's see if anybody has experienced the same and can advise for you anything.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans