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

DEVELOPERS FORUM - Ho to delete a relationship item from a client method.

ransok - Thursday, September 18, 2014 6:34 AM:

Hi ,

I need to delete an item's relationship items from a Dropdown's OnChange event. I tried two ways. Neither worked.

Dropdown-OnChange:

var thisItem = document.thisItem;

var deleteRels = inn.newItem("Mappings","get");
       deleteRels.setAttribute("where","[Mappings].source_id = '"+thisItem.getID()+"' ");
       deleteRels = deleteRels.apply();

Facing an error with this code : Event handler failed with message: TypeError: id is null

I tried in another way

var getRels = inn.newItem("AM_SWLIC_MachineMappingsRels","delete");
      getRels.setAttribute("where","[AM_SWLIC_MachineMappingsRels].source_id = '"+thisItem.getID()+"' ");
      getRels = getRels.apply();
      if(getRels.getItemCount()>0)
        {
                 for(var c=0;c<getRels.getItemCount();c++)
                         {
                            var item_ = getRels.getItemByIndex(c);
                             item_.setAttribute("action","delete");
                             alert("deleted");
                          }
                         thisItem= thisItem.apply();
                     }

I am not facing any error with this code. But deleting is not happening. I tried item.setAction("delete");, still its not happening. How to make this happen?

Thank you.