Report to Find Items w/ Null Relationship

Good day all.  I am having a hard time trying to create a report to find Documents without files attached.  This is the current config.

Aras v11 SP10

s_Document - Poly Source for the following ItemTypes.

s_Delivered Document

s_Drawing

s_Parts List

s_Manual

s_Specification

s_RefLibrary

All of there ItemTypes have RelationshipTypes with File.  How do I create a report to return all of the Documents that do not have a file attached?  I tried to use a variation of the Query for an item and return its configuration example from the Programmers guide.  I changed all of the information from Part & BOM to s_Drawing and File.  When I Run Server Method, it produces an error of Not a single item.  Thank you for the help with this. 

Parents
  • Hi Nathan

    You can try something like below C# method.  itemswithoutFile  set has all items without file and itemswithFile  set has items with file.

    Verify the item type name highlighted below (s_Document is poly item and s_DocumentFile is relationship item type name)

    Innovator inn = this.getInnovator();
    HashSet<string> itemswithoutFile = new HashSet<string>();
    HashSet<string> itemswithFile = new HashSet<string>();
    Item allItemType = inn.newItem("s_Document", "get");
    allItemType.setAttribute("select", "id,item_number");
    allItemType = allItemType.apply();
    if (!allItemType.isError())
    {
    for (int i = 0; i < allItemType.getItemCount(); i++)
    {
    Item isFileExist = inn.newItem("s_DocumentFile", "get");
    isFileExist.setAttribute("select", "id");
    isFileExist.setProperty("source_id", allItemType.getItemByIndex(i).getID());
    isFileExist = isFileExist.apply();
    if (isFileExist.isError())
    {
    itemswithoutFile.Add(allItemType.getItemByIndex(i).getProperty("item_number"));
    }
    itemswithFile.Add(allItemType.getItemByIndex(i).getProperty("item_number"));
    }
    }
    return this;

Reply
  • Hi Nathan

    You can try something like below C# method.  itemswithoutFile  set has all items without file and itemswithFile  set has items with file.

    Verify the item type name highlighted below (s_Document is poly item and s_DocumentFile is relationship item type name)

    Innovator inn = this.getInnovator();
    HashSet<string> itemswithoutFile = new HashSet<string>();
    HashSet<string> itemswithFile = new HashSet<string>();
    Item allItemType = inn.newItem("s_Document", "get");
    allItemType.setAttribute("select", "id,item_number");
    allItemType = allItemType.apply();
    if (!allItemType.isError())
    {
    for (int i = 0; i < allItemType.getItemCount(); i++)
    {
    Item isFileExist = inn.newItem("s_DocumentFile", "get");
    isFileExist.setAttribute("select", "id");
    isFileExist.setProperty("source_id", allItemType.getItemByIndex(i).getID());
    isFileExist = isFileExist.apply();
    if (isFileExist.isError())
    {
    itemswithoutFile.Add(allItemType.getItemByIndex(i).getProperty("item_number"));
    }
    itemswithFile.Add(allItemType.getItemByIndex(i).getProperty("item_number"));
    }
    }
    return this;

Children
  • Gopikrishnan,

    Thank you for this information.  Since I am still new to Aras, I know that I am missing something with this.  I created the Method with the script and created a Report to run it.  When I run the report, a new tab opens and nothing is displayed. 

    Report

    Type - Generic

    Location - Server

    Target - Window

    Method - sm_Document_Files

    I changed the Item to s_Manual and the isFileExist to s_Manual File.  The s_Document doesn't have any relationships. 

    Thank you again for your help with this.