Forum Discussion

user123's avatar
user123
Ideator I
7 years ago

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

4 Replies

  • 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
    • user123's avatar
      user123
      Ideator I

       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 

      • Gopikrishnan's avatar
        Gopikrishnan
        Ideator I

        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