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,
  • Hi Kalle, Reading your use case, it seems like this could be accomplished more easily with a SavedSearch. You can choose to display this SavedSearch from the TOC and share it with any number of users. You can do this by following the steps below.
    1. Login as admin
    2. Navigate to the Parts in the TOC
    3. In the State column, type "Released"
    4. In the toolbar at the top, select Search > Save Search
      • Enter a label for this search, e.g. "Released Parts"
      • Enter the Identity to display this search for, e.g. "All Employees"
      • Check the "Show On TOC" box
      • Click the Save button
    5. Verify that the "Released Parts" saved search is displayed under the Parts ItemType
    If this doesn't fulfill your requirements, could you please let me know who gave this presentation at ACE? I can try to check in with them to see if I can get a copy of the code for this example. Chris ________________________________________ Christopher Gillis Aras Labs Software Engineer
  • As far as I can remember, I should create a new ItemType, and in it create a new onBeforeGet Server Event. The Server Event method should contain something like:
    this.setProperty("generation", "0");
    this.setAttribute("generation, "condition", "gt");
    Do you know which project on Github ArasLabs this might be?
  • This is what I have tried on my own: I have created a new ItemType:    In the item type I have added  a new server event:    The event should make it look at Part instead:    However, no results are returned:
  • Hi, I'm also interested in this usecase! The problem with regular advandched search is, that you have no control over the displayed properties. A separate ItemType also has the advantage that you can choose the TOC position yourself. Best regards, Angela
  • Hi KalleAnka, I maybe found a solution: 1. Create a new ItemType 2. Add your properties, e.g. item_number and name 3. Create a new "onGet" Server Event 4. Add the following code:
    Innovator inn = this.getInnovator();
    Item qryItem = inn.newItem(); 
    qryItem.loadAML( 
            "<Item type='Part' action='get' select='item_number,name' doGetItem='0'>" +
            "</Item>"
    ); 
    Item resultItem = qryItem.apply();
       
    return resultItem;
    Best regards! Angela
  • Short note. In my solution, the search bar and page controls does not work yet. I tried to pass the page, pagesize and maxRecords via AML, but I am not able to click through the pages anyway. Any ideas?
  • Hi Angelalp, It might work with:
    setType("Part");
    var item = apply();
    return item;
    in an "onGet" server method. However, I haven't tested it that thoroughly yet though.
  • Hi KalleAnka, many thanks for that! This seems to work really well, here are a few of my test results: Actions & Reports from the original Part ItemType can be reused, but must be linked manually in the new ItemType again. I do not think it´s possible to link the original Part Actions and Reports automatically. The only thing that makes some trouble is locking an item in the new ItemType. 1. Go to the new ItemType 2. Choose a Part 3. Click "Lock" -> Error message: Aras.Server.Core.ItemNotFoundException The error message points to the new ItemType and not to the original Part 4. Open a part and close it again 5. Now "Lock" works and references to Part So in my case "lock" works, but you have to open one Part first. The behavior stays that way until you log out. All other options like search bar and page controls work fine.
  • Aha, that is weird! Would be neat if there was a more robust way to accomplish this.
  • I made some tests with the instance_data property of the new ItemType and set it manually to "Part" via SQL. This seems to improve the locking behavior, but I am not sure what it actually does. You can use this query to find the current value in a new database view:
    SELECT        KEYED_NAME, INSTANCE_DATA 
    FROM            innovator.ITEMTYPE
    WHERE        KEYED_NAME LIKE N'%YOUR_NEW_ITEMTYPE%') 
    The following three also don´t work: - Save As - Where used - Structure browser All three link to the new ItemType and not to original Part. The behaviour makes sense. But especially "Save As" would be cool feature. In quite 90% of all cases our users use Save as to create a new Part. Right now the new ItemType is just a better version of SavedSearch. With "Save As" included it would become really powerful. Do you know, who gave the presentation about this topic? I was at ACE Europe 2016 but did not have time last year.