How to create a new Part TOC menu item that does a custom search?

Hi, On the ACE 2017 Europe conference, a technique that utilized Federated Data to add a TOC menu item that did a custom search was showcased. In my case, I want to add a new TOC menu item, besides the Part menu item, that searches among Released Parts. I.e., the menu item should be called "Parts Released", clicking it and then clicking the "Run Search" button should return a list of parts that are released. On the conference, they said that I should create a new dummy ItemType, and redirect its requests to the real Part by modifying the onBeforeGet to server event. Apparently this is related to data federation according to the presenter. However, I do not remember the exact steps to implement this. I got the impression that there should example code demonstrating this on Aras' GitHub page. However, I have browsed through several pages of Aras' repositories on GitHub, and I cannot find any project that sounds to be what I am looking or. Does anybody know how to achieve what I am asking for? Or where sample code can be found? Please tell me if you want me to clarify anything in my description. Thanks,
  • Maybe we need to also add the method to the server events onUpdate for locking to work and onAdd for Save as to work. I believe the KEYED_NAME, INSTANCE_DATA columns are just for finding out the table name of an item type, which might be needed if you are going to write SQL instead of AML.
  • I think we are getting closer. onAdd and onUpdate - of course! With these two lock and unlock of existing Parts work fine. Save As is still optimizable. After Save As a new copy of the Part is generated, but users have to refresh the grid and the new Item is not shown in a separate window automatically. Most users will high-likely create 5-6 Part copies until they realize that they have to refresh the grid. Maybe this can be solved with some extra javascript logic. After Save As the new Part-copy cannot be unlocked in the grid -> Aras.Server.Core.ItemNotFoundException Unfortunately there is no onLock Method option that could be used here.
  • Also getting the Aras.Server.Core.ItemNotFoundException error when trying to lock existing items from the grid.
  • I currently also see exception some times. Also my Javascript "update the grid" attempts have so far been unsuccessful. But I have not given up yet, I have been looking for exactly these kind of function for an eternity.
  • How are you trying to update the grid with JS? I took a quick look at it, but I couldn't figure out how to attach a server event to the grid's form. I guess it's the form Core_ItemGridLayout that renders the grid, but I might be wrong. Since no form is specified in the Part ItemType's TOC View relationship, or in our custom Part ItemType for that matter, I assume it automatically falls back on the standard grid. But maybe it's overkill to try to override the default grid. Perhaps it's possible to add a JS method under the ItemType's Server Events or Client Events that gets called whenever the item is saved. I guess you could escape the item's tab by using parent in JS and then locate the grid iframe which seems to be named work, i.e. parent.document.getElementById('work').
  • Nice to see that I am not the only person who has low respect for items containing the term "Core" :-) Welcome to the dark side! But I don´t thnk we should kill the main grid (maybe later... :-)  ). Creating a customized TOC view will high likely not solve the problems with the Actions that link to the false tables. I made some attempts with JS. Mostly in the ItemType tab “Client Events” (event = onAfterNew). Problem: The events only react on changes in the new ItemType, not in Part. The whole issue is more in direction of Federation, which I have to deal with the next weeks anyway. But maybe we should just think more radical. In summary, the following functions are currently causing problems: - Save As - Lock / Unlock - Structure Browser / Where Used (lower priority for me right now) All of them have the same fundamental problem. The button actions link to the wrong tables. But they have one thing in common: All of them are CUI elements! (if you use SP9 or above). Instead of modifying the ItemTypes or Methods, why not get rid of the standard Actions and use own CUI buttons that do the work right? Something similar is e.g. done in the ItemType InBasket, where lock/unlock is replaced with claim/unclaim.
  • Proof of concept: Custom Lock button
    var inn = this.getInnovator();
    
    var topWindow = aras.getMostTopWindowWithAras(window); 
    if (topWindow.work && topWindow.work.grid) { 
        var workFrame = topWindow.work; 
        
        // var selectedIds = workFrame.grid.getSelectedItemIds(',').split(',');
        var id = workFrame.grid.getSelectedID();
        
        var item = inn.getItemById("Part", id);
        item.setAction("lock");
        // item.setAttribute("doGetItem", "1");
        item = item.apply();
    
        if (item.isError()) {
    	    return aras.AlertError(item.getErrorString());
        }
        // todo: Refresh Grid of new ItemType
        // parent.onRefresh(); // don´t work
    }
    Locks the Part without error message. But refreshing the grid of the new ItemType don´t work.
  • My PLM tactic is to wait long enough for things to solve themselves. The following code can be used for custom buttons for Lock, Unlock and SaveAs:
    var inn = this.getInnovator();
    
    var topWindow = aras.getMostTopWindowWithAras(window); 
    if (topWindow.work && topWindow.work.grid) { 
        var workFrame = topWindow.work; 
    
        var id = workFrame.grid.getSelectedID();
        
        var item = inn.getItemById("Part", id);
        item.setAction("copy");
        // item.setAction("lock"); 
        // item.setAction("unlock");
        item.setAttribute("doGetItem", "0");
        item = item.apply();
        if (item.isError()) {
    	 return aras.AlertError(item.getErrorString());
        }
        main.work.searchContainer.runSearch();
    }
    
    return item;
    
    Works without error messages and also the grid is updated. The rest should be just some CUI configuration.
  • Sample -> used in tab "Client Style" github.com/.../custom-itemtype-view Fixes Save, Save As, Lock, Unlock, Structure Browser and Where Used. Only creating a new Item still links to the wrong db-instance.
  • These two lines in a JS Methods in 'Client Events' solves the "New Item" issue. Creating a new Item in the TOC now also leads to Part.
    inDom.setAttribute('type','Part');
    top.aras.evalMethod('OnShowItemDefault', inDom, inArgs);