<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.aras.com/community/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/f/development/36948/update-parent-item-when-relationships-tab-is-changed</link><description>Good day all, 
 I have ItemType sm_ITA with a Relationship of sm_ITA_Assignment. sm_ITA_Assignment (Assignments) is not related to another ItemType. When an Assignment is added or deleted I need the sm_license_count property of the parent sm_ITA to be</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/thread/7828?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 13:38:11 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:d50f30dd-201c-4db5-a073-0efdefb7b919</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Thanks for this additional information! Then I will stick to the classic query variant :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/thread/7827?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 13:29:51 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:2aa77deb-ca83-4a24-886c-8c54c76e3b4f</guid><dc:creator>alaxala</dc:creator><description>&lt;p&gt;Unfortunately this is not possible. While changed&amp;nbsp;relationships must be present in the &amp;quot;this&amp;quot; item node to make changes in the database, unchanged&amp;nbsp;relationships are never present in. So,&amp;nbsp;we can&amp;#39;t avoid additional query.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/thread/7825?ContentTypeID=1</link><pubDate>Tue, 14 Dec 2021 10:20:18 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:48309325-9a99-452a-bfd2-35786d7d5312</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Alaxala,&lt;/p&gt;
&lt;p&gt;thanks for this code sample! Haven&amp;acute;t seen this variant before. As far as I see, you addRels and delRels variable mainly contains relationships that has been recently added/deleted to the item and then recalculates the property based on the changes. That&amp;acute;s a smart solution. I have done something similar in the past but in much more complicated way.&lt;/p&gt;
&lt;p&gt;Do you also have a variant, that can catch all existing relationships this way?&amp;nbsp;I want to analyze all of my relationship to find a few specific one with certain properties. Would be a big improvement if I could avoid a get query.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/thread/7614?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 12:58:32 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:90f9308f-a7ad-468e-ae23-8dea0c3938b8</guid><dc:creator>Nathan H.</dc:creator><description>&lt;p&gt;alaxala,&lt;/p&gt;
&lt;p&gt;Thank you for this code!&amp;nbsp; It works perfectly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update Parent Item when Relationships Tab is Changed</title><link>https://www.aras.com/community/thread/7612?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 09:40:24 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:2397d2fe-4442-4a53-b509-807c89d43538</guid><dc:creator>alaxala</dc:creator><description>&lt;p&gt;Try this code attached to OnBeforeUpdate and OnBeforeAdd server events sm_ITA item type&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;var addRels = this.node.SelectNodes(&amp;quot;Relationships/Item[@type=&amp;#39;sm_ITA_Assignment&amp;#39; and @action=&amp;#39;add&amp;#39;]&amp;quot;);
var delRels = this.node.SelectNodes(&amp;quot;Relationships/Item[@type=&amp;#39;sm_ITA_Assignment&amp;#39; and @action=&amp;#39;delete&amp;#39;]&amp;quot;);
string stcurlicenses = this.getProperty(&amp;quot;sm_license_count&amp;quot;);
int curLicenses = string.IsNullOrEmpty(stcurlicenses) ? 0 : Int32.Parse(stcurlicenses);
curLicenses = curLicenses + addRels.Count - delRels.Count;
this.setProperty(&amp;quot;sm_license_count&amp;quot;, curLicenses.ToString());
return this;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>