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
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