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 Chris, I can confirm that this one works well in SP11 too! Thanks for the code! And as I sometimes feel like the queen of usability. I have a brilliant idea of improving the default behavior of "Save As"! Standard "Save As" is a nice function, quite 80% of our new Parts are created with Save As. But it only works when the original Item is not openend. In reality users most of the time forgot to close the original Item. Save As related question somehow cover 0.42% of my Admin time. How about modifying the Method "cui_default_mwt_onSaveAsCommand" like this?
    var topWindow = aras.getMostTopWindowWithAras(window);
    var workerFrame = topWindow.work;
    
    // START custom code: Check if Item is already opened in tab or tearoff window
    // Doesn´t work for Actions, Methods, Reports,...
    // Works for Parts, Documents, Identities, Permissions,...
    var id = workerFrame.grid.getSelectedID(); // get id of item selected in grid
    var openWindows = aras.windowsByName;
    
    for (var winName in openWindows) {
        var win = openWindows[winName];
        
        var winItem = win.thisItem;
    
        if (winItem && winItem.node.id === id)
        {
            return alert("'Save As' can not be applied to opened items. Please close the corresponding item first.");
        }
    }
    // return alert("Window is not open" ); // Debug
    
    // END custom code
    if (workerFrame && workerFrame.onSaveAsCommand) {
    	workerFrame.onSaveAsCommand();
    }
    This code improves Save As for all end-user relevant ItemTypes like Part, Document, etc. For some reason, it does not work for code-heavy item types like Method or Reports. Would be happy if somebody else could give this one a try! Angela
Reply
  • Hi Chris, I can confirm that this one works well in SP11 too! Thanks for the code! And as I sometimes feel like the queen of usability. I have a brilliant idea of improving the default behavior of "Save As"! Standard "Save As" is a nice function, quite 80% of our new Parts are created with Save As. But it only works when the original Item is not openend. In reality users most of the time forgot to close the original Item. Save As related question somehow cover 0.42% of my Admin time. How about modifying the Method "cui_default_mwt_onSaveAsCommand" like this?
    var topWindow = aras.getMostTopWindowWithAras(window);
    var workerFrame = topWindow.work;
    
    // START custom code: Check if Item is already opened in tab or tearoff window
    // Doesn´t work for Actions, Methods, Reports,...
    // Works for Parts, Documents, Identities, Permissions,...
    var id = workerFrame.grid.getSelectedID(); // get id of item selected in grid
    var openWindows = aras.windowsByName;
    
    for (var winName in openWindows) {
        var win = openWindows[winName];
        
        var winItem = win.thisItem;
    
        if (winItem && winItem.node.id === id)
        {
            return alert("'Save As' can not be applied to opened items. Please close the corresponding item first.");
        }
    }
    // return alert("Window is not open" ); // Debug
    
    // END custom code
    if (workerFrame && workerFrame.onSaveAsCommand) {
    	workerFrame.onSaveAsCommand();
    }
    This code improves Save As for all end-user relevant ItemTypes like Part, Document, etc. For some reason, it does not work for code-heavy item types like Method or Reports. Would be happy if somebody else could give this one a try! Angela
Children
No Data