Event Handler Failed OnInsertRow

オフライン

Hi 

I am new to Aras so i dont really know what am doing. However i have been working on a small project where i require a row event.  when i add the below code to the Relationship type with the event handler OnInsertRow i keep getting an error.  can someone please help me i dont know what am doing wrong. 

var parent_item = parent.thisItem;
var parts = parent_item.getRelationships("parts");
var newItemNum = parts.getItemCount(); 
setRelationshipProperty(relationshipID, "sort_order", newItemNum);
Thank  you
Parents
  • Hi 

    I assume you are trying to update sort order of a relationship. Can you confirm the relationship name is correct. You can go to Administrators --> Item Type --> Search Part and see what is the exact relationship name under relationship tab.

    Lets assume you are updating the Part BOM, then your code should be:

    var parent_item = parent.thisItem;
    var parts = parent_item.getRelationships("Part BOM");
    var newItemNum = parts.getItemCount(); 
    setRelationshipProperty(relationshipID, "sort_order", newItemNum);
    Thanks
    Gopikrishnan R
  • オフライン in reply to Gopikrishnan

     Hi

    Thank youy so much for replying, 

     So i have main item type called Design_Parts  with has a relationship with part_List and that has a  relationship item which is called Design_Part _list . so as far as my understanding goes i have  gone to my DesignPart itemType clicked on Relationship and  clicked on  view relationshipType. In there it has a tab called Grid event and thats where i have maneged to  put this.

     

    so my code goes something like this but currently it doesnt do anything apart form give me a eror. 

    var parent_item = parent.thisItem;
    var parts = parent_item.getRelationships("Design_Parts");
    var newItemNum = parts.getItemCount(); 
    setRelationshipProperty(relationshipID, "sort_order", newItemNum);
     I want something like the screenshot below . so when the end users add partsit will automatically be like part 1 part 2 so on. and currrently its not doing that and i dont understand where am going wrong. 

     Again thank you soo much for your help. 

    USER123 

  • オフライン in reply to user123

    Hi

    In this case, the relationship should be 'part_List'. Also ensure that you want to update the sort_order column or item number column.

    var parent_item = parent.thisItem;
    var parts = parent_item.getRelationships("part_List");
    var newItemNum = parts.getItemCount(); 
    setRelationshipProperty(relationshipID, "sort_order", newItemNum);

    Thank You

    Gopikrishnan R

Reply
  • オフライン in reply to user123

    Hi

    In this case, the relationship should be 'part_List'. Also ensure that you want to update the sort_order column or item number column.

    var parent_item = parent.thisItem;
    var parts = parent_item.getRelationships("part_List");
    var newItemNum = parts.getItemCount(); 
    setRelationshipProperty(relationshipID, "sort_order", newItemNum);

    Thank You

    Gopikrishnan R

Children
  • オフライン in reply to Gopikrishnan

     Hi 

    I have done exactly what you said and i still get a internal error:event handler failed. I really dont know what i am doing wrong.   Also the field label is called sort_order.  Just to confirm that this event handler is meant to go into the relationshipItemType right    i have been working on this for the past few days and i cant seem to get it  right.  Please help me. Is there  a another way i can do this and still get the same output