This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to delete relation ship before edit

Hi guys

New a method like this

Item mainItem = this.newItem("MainItem", "get");
mainItem = mainItem.apply();

//Add Relationship
var relItem = innovator.newItem("Detail_File","add");
mainItem.addRelationship(relItem) ;

var relItem = innovator.newItem("Detail_File","add");

//delete relationship
//I want to delete fileID_A Relation  (But right now not save in DB so i can't get fileID_A Sys ID to delete)


How can I do?

  • Hello Michelle,

    You can delete the relationship from this structure before you apply the item by using mainItem.removeRelationship(relItem);. The removeRelationship function expects an argument of an Item object, so you will first need to get the item you want to delete. Presumably, you're performing some kind of check to determine when the item should be deleted, so your code could look something like this:

        Item relFiles = mainItem.getRelationships("Detail_File");
        for (int i = 0; i < relFiles.getItemCount(); i++)
            Item relFile = relFiles.getItemByIndex(i);
            // do your logic on relFile here
            // if (relFile.getProperty("XXX") != "XXX")


    Christopher Gillis

    Aras Labs Software Engineer.