Check if Item is already openend in tab or tearoff window

Hi, I wonder if it´s possible to check if an Item (e.g. Part) is already openend on client side? I plan to improve the following use case: A button event triggered from a Form shall trigger a change in another Item. If this Item are already opened in the clients tab or tearoff windows, the change will apply, but the users often do not notice that something happend. So they often trigger the same Method serveral times until they finally try the refresh button (or call the Admin...). It would be really cool if I just could do a simple precheck if the target item is already opened. If yes, a simple return message like "Please close the Item xy first before starting this function." would already be a big help. Any ideas if this is possible at all? Thanks for your help! Angela
Parents
  • Hi Angela, In a JavaScript method, you have access to which windows are open via the aras object. The sample code below checks if an item with a specific ID is already open and should work both if the item is open in a tab or in a separate window.
    var openWindows = aras.windowsByName;
    for (var winName in openWindows)
    {
    var win = openWindows[winName];
    var winItem = win.thisItem;
    if (winItem && winItem.node.id === "MY_ITEM_ID")
    {
    return alert("window is open");
    }
    }
    return alert("window is not open");
    Please note that I wrote this sample in SP15. If you notice it doesn't work as expected in your environment, let us know what version you are using, and we can provide an updated sample. Chris
    Christopher Gillis Aras Labs Software Engineer
Reply
  • Hi Angela, In a JavaScript method, you have access to which windows are open via the aras object. The sample code below checks if an item with a specific ID is already open and should work both if the item is open in a tab or in a separate window.
    var openWindows = aras.windowsByName;
    for (var winName in openWindows)
    {
    var win = openWindows[winName];
    var winItem = win.thisItem;
    if (winItem && winItem.node.id === "MY_ITEM_ID")
    {
    return alert("window is open");
    }
    }
    return alert("window is not open");
    Please note that I wrote this sample in SP15. If you notice it doesn't work as expected in your environment, let us know what version you are using, and we can provide an updated sample. Chris
    Christopher Gillis Aras Labs Software Engineer
Children
No Data