Update Parent Item when Relationships Tab is Changed
- 4 years ago
Try this code attached to OnBeforeUpdate and OnBeforeAdd server events sm_ITA item type
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:e6c7537c-0d26-4f90-8421-7423cc484fd4:type=csharp&text=var%20addRels%20%3D%20this.node.SelectNodes%28%22Relationships%2FItem%5B%40type%3D%27sm_ITA_Assignment%27%20and%20%40action%3D%27add%27%5D%22%29%3B%0D%0Avar%20delRels%20%3D%20this.node.SelectNodes%28%22Relationships%2FItem%5B%40type%3D%27sm_ITA_Assignment%27%20and%20%40action%3D%27delete%27%5D%22%29%3B%0D%0Astring%20stcurlicenses%20%3D%20this.getProperty%28%22sm_license_count%22%29%3B%0D%0Aint%20curLicenses%20%3D%20string.IsNullOrEmpty%28stcurlicenses%29%20%3F%200%20%3A%20Int32.Parse%28stcurlicenses%29%3B%0D%0AcurLicenses%20%3D%20curLicenses%20%2B%20addRels.Count%20-%20delRels.Count%3B%0D%0Athis.setProperty%28%22sm_license_count%22%2C%20curLicenses.ToString%28%29%29%3B%0D%0Areturn%20this%3B]