Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Commerce forum / How to pass selected s...
Commerce forum
Suggested answer

How to pass selected sales transaction line in shopping cart to CRT

Posted on by

I have a prospective scenario. The solution is about to create a new operation and pass the selected sales transaction line in shopping cart as parameter to the new operation.

Example behavior:

Reference to the "View available discounts" operation. The process is, to choose an item in cart and click the operation button, The command "GetAvailablePromotionsServiceRequest" has "SalesTransaction" object as parameter. I would like to do the same behavior.

SalesTransaction salesTransaction = new SalesTransaction();
salesTransaction.CartType = CartType.Shopping;
salesTransaction.SalesLines.Add(ConstructSalesLine("888842543067"));
CalculatePricesServiceRequest request = new CalculatePricesServiceRequest(salesTransaction);
GetPriceServiceResponse response = runtime.Execute<GetPriceServiceResponse>(request, new RequestContext(runtime));

GetAvailablePromotionsServiceRequest getAvailablePromotionsServiceRequest = new GetAvailablePromotionsServiceRequest(salesTransaction);
GetAvailablePromotionsServiceResponse getAvailablePromotionsServiceResponse =
requestContext.Execute<GetAvailablePromotionsServiceResponse>(getAvailablePromotionsServiceRequest);

Questions: - 

1. Is there any examples in RetailSDK\Document to pass the selected sales cart as parameter to CRT?
2. If no example, please kindly guide the command in Cloud POS and CRT.   

  • Suggested answer
    Guanghui Profile Picture
    Guanghui on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

     // Try to load the transaction

                   var getCartRequest = new GetCartRequest(

                       new CartSearchCriteria(cartId, cartVersion),

                       QueryResultSettings.SingleRecord,

                       includeHistoricalTenderLines: false,

                       ignoreProductDiscontinuedNotification: null);

                   var getCartResponse = context.Execute<GetCartResponse>(getCartRequest);

                   return getCartResponse.Transactions.SingleOrDefault();

  • Guanghui Profile Picture
    Guanghui on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

    Code has delivered to customer through email

  • pka Profile Picture
    pka on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

    Hi Ram Shenkar

    Thank you.  I'll try that.      

  • pka Profile Picture
    pka on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

    Hi Leonard

    Thank you.  I'll join the group & try.  

  • Suggested answer
    Ramshenkar Profile Picture
    Ramshenkar on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

    You can get the current cart in POS typescript code by implementing the cart controller. It will provide the current cart and selected cart lines. You can customize or change CartViewController.ts file as per your requirement and refer in your custom operations handler in POS.

    Refer sample extension :  RetailSDK\POS\Extensions\SampleExtensions\ViewExtensions\Cart\CartViewController.ts

    Documentation :

    docs.microsoft.com/.../cart-view-handlers

    In case you want the current cart in CRT you need transaction id to get the current cart details. You can fetch the transaction details using GetSalesTransactionDataRequest. In most of the CRT request you can get transactionid.

    Hope this answer your question.

  • Suggested answer
    Leonard Yang Profile Picture
    Leonard Yang 10 on at
    RE: How to pass selected sales transaction line in shopping cart to CRT

    Hi AeyPKA,

    You can post your question to Yammer. May get more ideas from other experienced engineers.

    www.yammer.com/.../

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans