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 remove the parts EBOM relationship ?

Anonymous - Thursday, January 13, 2011 12:02 PM:

Hi All,

 from Visual Studio  I'm using a C# , I'm able to insert some new Parts inside ARAS system, then I'm able to insert also an EBOM relationship between some parts previously inserted.

My question is Exist a method , to remove/modify one EBOM relationship structure of my Father Part Number ?

am I able to remove all relationship or modify something for example the Qty , or another specific relation info ?

someone can help me by simple example

thanks a lot

Marco.



Ronan - Thursday, January 13, 2011 1:23 PM:

Hi Marco,

  • Use Item.removeRelationship to break a parent-children relationship
  • Modifying qty or another specific relation info is done by modifying the Item associated to the Relationship, use Item.setProperty / Item.setPropertyAttribute / Item.setAttribute

You should have a look at the Innovator API Reference (it's also available as a .chm in your Aras install dir, at <ARASDIR>InnovatorClientWebHelpAPIReferenceWinHelpInnovatorAPIReference.chm), the methods that interest you are in the /IOM/Item/Methods section.

Have fun.

 



Ronan - Thursday, January 13, 2011 1:27 PM:

Code samples are right under your fingers: inside Innovator, go to Admin/Methods, then switch to advanced search, add a search criteria, and use "Method code" LIKE *removeRelationship*



Anonymous - Friday, January 14, 2011 4:26 AM:

Hi Ronan,

thank you very much for your answers, really I'm already tried the API method that you mentioned , but the relationship remain into the Aras database ...:-(

Probably I missing some  transition close like  sql commit,  ...  I will check better  and let you know.

Marco.



Ronan - Friday, January 14, 2011 9:02 AM:

You're probably missing Item.apply()



Anonymous - Monday, January 24, 2011 10:16 AM:

Hi Ronan,
I'm using this code from my client application, But seems that the relationship cannot remove from Aras system...
Can you help me ?
thanks
Marco.
   private void DeleteRelationShip( Item parent )
    {
 
      parent.lockItem();
      //
      // se non faccio prima il fetch la getrelation successiva non funziona
      Item bom = parent.fetchRelationships( "Part BOM" ).getRelationships( "Part BOM" );
      Item bbom = parent.getRelationships( "Part BOM" );
 
      int ccount = bbom.getItemCount();
 
      for ( int i = 0; i < ccount; i++ )
      {
        Item relation = bbom.getItemByIndex( i );
        parent.removeRelationship( relation );
      }
      parent.apply();
      //
      //
      parent.unlockItem();
    }
 
    private void button3_Click( object sender, EventArgs e )
    {
      string code = "10346";
      Item it = GetItem( "Part", code );
      DeleteRelationShip( it );
    }
 


Ronan - Friday, January 28, 2011 10:02 AM:

Hey,

Hmmm nothing makes my eyes bleed at first sight, and you properly lockItem() / unlockItem()

  • Do you have an error message? If yes, what is it?
  • Have you tried debugging? If yes, when are you kicked?



RobMcAveney - Friday, January 28, 2011 10:44 AM:

removeRelationship removes the relationship from your AML request.  It does not do submit anything to the server for processing.  To delete any item in Aras Innovator you need to use action="delete" in your request and either have an id or where attribute specified.  Try something like this:

// Get the parent Part and its Part BOM relationships
Item parent = this.newItem("Part","get");
parent.setProperty("item_number","10346");
Item bom = parent.createRelationship("Part BOM","get");
parent = parent.apply();
if (parent.isError()) return parent;

// Loop through the Part BOM relationships and delete them
bom = parent.getRelationships("Part BOM");
for (int i=0; i<bom.getItemCount(); i++)
{
    Item thisBom = bom.getItemByIndex(i);
    Item tmpItem = this.newItem("Part BOM","delete");
    tmpItem.setID(thisBom.getID());
    tmpItem = tmpItem.apply();
    if (tmpItem.isError()) return tmpItem;
}



Anonymous - Friday, January 28, 2011 11:52 AM:

Hi Rob,

you are the best !  now working well.

Are you an ARAS guru :-)  ?

thanks again, Best

Marco.