Hi everybody,
I'm trying to figure out a way to pass complex data from one page to another and open that page in another tab.
Let me explain my purpose. I have the Purchase Order form opened in the browser. When I click on 'Receive PO' link I want to open that in another tab (or new browser window) but it should be populated with PO info and the PO Lines which still have remaining quantities. So, I need to pass the complex object to that page but I'm not sure how can I do it (what mechanism to use for passing objects between different browser sessions).
I tried before using the service, but I found it didn't work. I can not use object as parameter (as far as I understand parameter needs to be something simple) (e.g. I can pass the PO Id, but it would not help me much as I could have changed that PO and therefore I can not simply retrieve its info in the other page, I'd like to pass it over).
Any ideas of how should I proceed?
Thanks a lot in advance.
UPDATE. I'm going to re-try service idea
https://stackoverflow.com/questions/22408790/angularjs-passing-data-between-pages as perhaps I didn't implement it correctly in my original try.
UPDATE2. This doesn't work for me, perhaps because I'm attempting to open the page in a new tab and the service being reset.
This is my code:
services.Vendor.setPurchaseOrder(this.model);
const linkUrl = "RetailInventory/Receivers#/new/" + this.model.internlPo;
window.open(linkUrl, "_blank");
And in the receivers I try:
this.purchaseOrder = {};
const order = SW.serviceLoader.Vendor.getPurchaseOrder();
this.logInfo("Attempting to retrieve PO from Vendor service");
if (!_.isEmpty(order) && order.hasOwnProperty("internlPo")) {
this.logInfo("Successfully retrieved PO from the Vendor service");
this.purchaseOrder = order;
this.model['internlPo'] = order.internlPo;
}
else {
if (SW.serviceLoader.StateParams.internalPo) {
this.model['internlPo'] = SW.serviceLoader.StateParams.internalPo;
this.doPurchaseOrderLookup();
}
}
The first loop is never hit.
If it's not broken, fix it until it is.
My Blog