web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

How to call return transaction from custom code for POS

(0) ShareShare
ReportReport
Posted on by 1,457

I have a custom view that will list customer orders and carry out transactions in one view. 

Standard POS has the customer orders in Find and Manage orders view (OrderSearchView) and the carry out transactions in Store transactions (ShowJournalView). On the customer details view there is an All Orders just above the Order History panel for the specific customer. The ideal would have been to use this all orders which in the backend also calls ShowJournalView. However there is no filters on this. Looking in HQ where it retrieves the data, I can see why. It uses 3 different selects and then combine it.

We have the the feature Unified return processing experience in POS turned on which means we should be able to return both store transactions and customer orders on .Return Transaction. 

My custom view has to work similarly to the "All orders" but have filters. Everything works find. I added the return button. Looking in Pos.viewModels.js on how the return transaction is called, I see if it is a customer order it calls "SalesInvoicesView". I am calling it and it works the same as when one will do a return from the All orders or the Find and Manage Orders screen.

For a sales transaction I use the same logic that I could find in Pos.viewModels.js and that is that it passes in the sales order as a parameter and then calls the operation for Return Transaction. However the Return  Operation is still calling SalesInvoiceView instead of directly the Returnable Products view. The only reason I can think of is that the parameter it receives is the sales order and maybe it wants the RetailTransactionTable instead? Because the Retun transaction operation calls the salesInvoiceView, it behaves the same as for a customer order in that it prompts for a reason code. 

How can I change my code that it calls the returnable products view same as the return button on the Store transactions?

Below is the code on how to call the return transactions as I found it in Pos.ViewModels.js, but somehow  return operation is calling SalesInvoiceview:

var options = {
    salesOrder: salesOrder
    };
return TMC.Commerce.Operations.OperationsManager.instance.runOperation(TMC.Commerce.Operations.RetailOperation.ReturnTransaction, options)
    .map(function (result) {
        if (result && !result.canceled) {
            this._context.navigator.navigate("legacy-core", "CartView");
        }
    }).always(function () {
        this.isPageModeBusy(false);
        this._customViewControllerBaseState.isProcessing = false;
    }).getPromise();

If I change the code to not pass in the sales order but only a receipt number, then it calls directly the Return transaction but it opens the dialog called "Search orders" which means it doesn't respect the receiptId I pass in as a parameter.

var options = {
    receiptNumber: vReceipt
};
return TMC.Commerce.Operations.OperationsManager.instance.runOperation(TMC.Commerce.Operations.RetailOperation.ReturnTransaction, options)
    .map(function (result) {
        if (result && !result.canceled) {
            this._context.navigator.navigate("legacy-core", "CartView");
        }
    }).always(function () {
    this.isPageModeBusy(false);
    this._customViewControllerBaseState.isProcessing = false;
}).getPromise();

If I navigate to ReturnTransactionView (found the name when looking at the developer tools), it also opened the dialog even when I pass in the salesOrder.

So, do I re-find the sales order using the transactionID, incase that includes information in the backend that I don't know about or how do I get it to open the return transaction the way it opens when using "All orders" on customer detail view > Order history for a carry out transaction?

Any help is much appreciated.

I have the same question (0)
  • huijij Profile Picture
    19,811 on at

    Hi Retha,

    Obviously the parameter you modified is not valid, so I suggest you go to the backend and check the method called by Pos.ViewModels.js to see if it supports passing in that parameter. If not, you will need to redevelop to make the interface.

  • Retha Profile Picture
    1,457 on at

    I did get the parameter from Pos.ViewModels.js . So if it is not valid, then Microsoft has code in there that isn't used.

    I re-read the salesOrder using GetSalesOrderDetailsByTransactionIdClientRequest/Response and this time it did go directly to the RetailTransactionView. So finding it with TransactionId must pull in values that it needs to identify it for the RetailTransactionview.

    However I get the following error after selecting the returnable product and then click on the return button that will take one to the cart. Note that if I look up the exact same record in Store transactions and perform the same steps, it doesn't stop me, it take same to the cart. However, when I look in the developer tools, I can see that it also generates the error. The only difference is that it ignores the error.

    Refused to execute inline script because it violates the following Content Security Policy directive: "'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash (''), or a nonce ('nonce-...') is required to enable inline execution.

    So what do I need to put where in my code to also ignore the above error?  Do you know by chance?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 299 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 183 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 117 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans