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 - Method in a RelationShip - PART BOM

Remi - Tuesday, August 4, 2009 11:06 AM:

Hello,

  I want to add a method from the BOM. In fact I want to call a specific method when someone is clicking on the field/properties Quantity.

I try several ways without sucess :

- Add a method in the RelationShip :

      I try with the method SetAction or with something like that :

        var thisItem = parent.thisItem;

         var thisRel = thisItem.getItemsByXPath("//Item[@id='" + relationshipID + "']").getItemByIndex(0);
         thisRel.getAttribute("quantity").onfocus = function(){  alert("test");    };

 

- Add a method in the PART BOM:

       this way is only working when the user click right and open the PART BOM but not when is he clicking on the Tab BOM fron the Part

  Thank you for you support, you have already help me so much,

 Regards



RobMcAveney - Tuesday, August 4, 2009 11:54 AM:

I think what you're looking for is a Grid Event.  Edit the Part BOM ItemType, right-click on the quantity Property and choose View Properties.  There is a tab on the Property form for events.  It sounds like you need the OnEditStart event.  You might want to start your method with a debugger; statement to see what local variables are available to you.  There are also a few OnEditStart Grid Events in the standard solutions -- check out method PE_AffectedItemGridHandler as an example.

As a side note, keep in mind that this method will only be run on the client.  You may want additional server-side validation if Part BOM items will be edited through any other means (method code, integrations, nash client, etc.) and you need the same rules enforced.

Rob



Remi - Wednesday, August 5, 2009 5:55 AM:

HI,

 Indeed this is the right way, I did not see that we can attach method directly for ItemType properties. It might be powerful.

 I am trying to get the value of the field is editing I think it is something like : this.getAttribute("id") .

 But I think I can find it by myself with the debugger but I don't know how to use it. I put at the beggining of the method :

 

  debugger;

 

But I don't see any difference in the execution.

Thanks a lot,

Regards, Remi



RobMcAveney - Wednesday, August 5, 2009 10:11 AM:

You can use either Visual Studio or the free Microsoft Script Debugger to debug.  There may be other options as well, but I usually use Visual Studio.  You'll also need to uncheck the "Disable Script Debugging" option in the IE settings.  See Section 10 of the Programmer's Guide, available here: http://www.aras.com/support/documentation/.

Rob



Remi - Wednesday, August 5, 2009 11:02 AM:

Indeed the Debugger is very useful!

if it can helps someone here is my method to get an Attribute in a relationship grid :

 if (!parent.isEditMode) {return;}
  var relshipNd = parent.item.selectSingleNode("Relationships/Item[@id='" + relationshipID + "' and related_id/Item]");
 
   var link = top.aras.getItemProperty(relshipNd, "quantity");

 

Hope that will help someone else!

Regards, Remi