<?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 Parents Item</title><link>https://www.aras.com/community/f/development/3922/update-parents-item</link><description>Hi

I create item &amp;quot;ATEN_VPN&amp;quot;&amp;#160; add relationship &amp;quot;ATEN_VPN_File&amp;quot;.

When I save ATEN_VPN I need to know how many count in &amp;quot;ATEN_VPN_File&amp;quot;&amp;#160; and save in ATEN_VPN

In&amp;#160;ATEN_VPN Server Event &amp;quot;onBeforeUpdatae&amp;quot;&amp;#160; add this method

Code:

Innovator innovator = this</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Update Parents Item</title><link>https://www.aras.com/community/thread/2032?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 09:38:48 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:9028dfed-805f-4326-acef-6544f2cf184f</guid><dc:creator>Christopher Gillis</dc:creator><description>Hi Michelle,

I think the issue you&amp;#39;re running into is related to updating the item within an onBeforeUpdate itself. You may be entering into an issue where each update of the item within the server event is triggering it&amp;#39;s own onBeforeUpdate event.

I was able to work around this issue in a test environment by simplifying the sample of code provided. Within the onBeforeUpdate event, we already have access to the item we want to check the relationships on through the context item (&lt;strong&gt;this&lt;/strong&gt;). Additionally, we don&amp;#39;t need to apply an edit since that will automatically take place once the onBeforeUpdate finishes. All that needs to be done is to set the property on &lt;strong&gt;this&lt;/strong&gt; before we return from the method. You can see the sample code that worked in my environment below.

&lt;pre&gt;&lt;code&gt;// Fetch any relationships that may not exist in this context
this.fetchRelationships(&amp;quot;ATEN_VPR_File&amp;quot;);
Item relationships = this.getRelationships(&amp;quot;ATEN_VPR_File&amp;quot;);
// Get the count of the relationships
int count = relationships.getItemCount();
// Store the count in the property on the item
this.setProperty(&amp;quot;_h_test&amp;quot;, count.ToString());
// And let the apply that will be called after this onBeforeUpdate save that property to the database
return this;&lt;/code&gt;&lt;/pre&gt;


Chris

&lt;hr /&gt;

Christopher Gillis

Aras Labs Software Engineer&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>