Not getting selected item in search dialog box

Hello,

I have a Document relationship on Part ItemType. I have added a method on "OnBeforeNew" client event of that relationship. When I add a new relationship from the form a search dialog box gets open and it shows me all the Document item present in the system. When I select the item in search dialog box and click on the green color tick on the top right, I get the details such as id and name etc in my method but when I double click the item in search dialog box then I dont get the item details in my method.

window.parent.findCurrentRelationshipsTab().itm - This is the line of code which gives me null value when I double clicks the row in search dialog.

Please sugggest me how to get the selected item search dialog box.

Parents Reply Children
  • Once I have the item I need to check that the selected item should not be present in any other Document relationship of Part. If it is not present anywhere else then only I sholud allow it to attach in the Document relationship.

  • I am also working on similar use case. Any solutions for the above mentioned use case.

  • Hi 

    Not sure your use case is getting the selected item in search dialog or not allowing user to select the document if it is used in any other parts. 

    If second is the use case, you can add custom search filter while opening the search dialog

  • My use case is getting selected Documents data ( Such as Doc No, id) in the Search Pop up dailog in a client method which is hooked to OnBeforeNew Client events of the Part Document Relationship Itemtype. 

    After getting the data, i will add some validation code.

  • var documentItems = aras.itemsCache.getItemsByXPath("//Item[@type='Document']");
    for (var i = 0; i < documentItems.length; i++)
    {
    var documentId = documentItems[i].id;
    var inn = this.getInnovator();
    var documentItem = inn.newItem('Document','get');
    documentItem.setID(documentId);
    documentItem = documentItem.apply();
    if(documentItem.isError())
    {
    return aras.AlertError(documentItem.getErrorString());
    }
    if(documentItem.getProperty("state") == "Preliminary")
    {
    aras.AlertError("Preliminary cannot be added.");
    return false;
    }
    }