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 - How to delete relathionship item with AML?

Boro - Tuesday, March 24, 2009 8:42 PM:

Hello,

I'm trying to develop a method of deleting the relathionship item. In this method, I set the query using AML.

excerpt from the code.------------------------------------------------------------------

var qryDel = inno.newItem();
   qryDel.loadAML(
   "<Item type='myItem' action='edit' id='myID'>" +
    "<Relationships>" +
     "<Item type='myRelationshipItem' action='delete'>" +
      "<related_id>myRelatedId</related_id>" +
      "</Item>" +
    "</Relationships>" +
   "</Item>"
   );
   var tmpItem = qryDel.apply();
   
if (tmpItem.IsError()){
 top.aras.AlertError(tmpItem.getErrorDetail());
 return;

----------------------------------------------------------------------------

If I excute this method, I get the following message.

"The update operation failed: Failed to apply the delete action to this relationship: Internal Error; failed to delete the item"

I have already developed a method of adding the relathionship item. This code works correctly only  changes "action='delete'" to "action='add'".  I also tried to change "action=''delete" to "action='get'", it returned a error message "No item found".

I couldn't find the detail of "action='delete'"  in Help and this forum.

How should I code it?



RobMcAveney - Tuesday, March 24, 2009 9:27 PM:

Hi Boro -

The delete action requires either an id or a where attribute.  The server doesn't allow you to delete by using criteria (it's protection against accidentally deleting more than you intended).  So you either need to specify the id of the relationship to delete (preferred) or use a where attribute like where="[MYRELATIONSHIPITEM].related_id='"+myRelatedId+"'".

Regards -

Rob



Boro - Wednesday, March 25, 2009 12:46 AM:

Rob

Thank you for a quick response, and I could resolve my problem thanks to your reply!!



rvdijk - Monday, March 12, 2012 3:49 PM:

Hi Rob, Boro,

I try to delete a relationship between a Part and Manufacturing Part (AML tab) by using AML. Reason; we took a shortcut in creating Parts by using the copy functionality in ARAS, changing only Part number and Name before saving. Result; hundreds of Parts with a wrong relationship.

I looked in this forum for AML to delete and maybe replace the relationship and found this post, however, I do not undestand how to write the code using the where attribute. Can (one of) you please help me with this?

Thanks in advance.

BR,

Rob



rvdijk - Monday, March 19, 2012 9:42 AM:

Figured out a way to do it. I looked for the relationship IDs in the SQL DataBase and hardcoded these in AML, e.g:

<Item type="Part AML" id"3ED85DB56EB1428DAE35D6CB12F1A770" action="delete">