Forum Post: RE: Identify changes in a Many-To-Many relationship

  • Thread starter Thread starter Gian Torralba
  • Start date Start date
Status
Not open for further replies.
G

Gian Torralba

Guest
Hi Stein, You cannot specifically use #before on many to many relationship as well as using the #id to return all ID's because it will only return a single ID. As Mani suggested, you can use the rbv_api.getRelatedIds() to return all ID's as a javascript array. What you can do is create a hidden lookup 1-Many to hold the previous ID's, create a trigger that will set the new value on the hidden lookup and then a trigger to compare which ID's are added or removed. Please follow the trigger hierarchy. Compare ID's Trigger After Update Update hidden lookup value (Update Field Value Trigger) After Update For trigger 1, you can check this sample code: var newIds = rbv_api.getRelatedIds("relName", parseInt("{!id}")); //main lookup var oldIds = rbv_api.getRelatedIds("relName", parseInt("{!id}")); //hidden lookup //Add your own javascript function to compare both arrays and remove the duplicates. For trigger 2, var ids = rbv_api.getRelatedIds("relName", parseInt("{!id}")); //relname of main lookup return ids.join(","); This will update the value of the hidden lookup field so it can be compared to the main lookup when the first trigger executes. Hope this helps. Thanks, Gian

Continue reading...
 
Status
Not open for further replies.
Back
Top