<?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>c# method with several functions</title><link>https://www.aras.com/community/f/development/3398/c-method-with-several-functions</link><description>Hi there,

I am trying to make a recursive method in c# to process some relationships in my product structure which is based on several itemTypes.

To do this I made different functions which are first called from a main.

The only way I found to get</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: c# method with several functions</title><link>https://www.aras.com/community/thread/837?ContentTypeID=1</link><pubDate>Wed, 13 Sep 2017 04:53:06 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:58dd21b6-f566-463d-839d-eaced33fb5e3</guid><dc:creator>Former Member</dc:creator><description>Thank you so much Christopher,

My code now runs!

Best regards&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: c# method with several functions</title><link>https://www.aras.com/community/thread/829?ContentTypeID=1</link><pubDate>Tue, 12 Sep 2017 13:49:24 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:3c67fa3d-9ec5-4ddd-9d9b-842fb561f185</guid><dc:creator>Christopher Gillis</dc:creator><description>Hello,

When creating a new Method item, you do not need to include a specific call to a &amp;#39;main&amp;#39; function. When you attach the Method code to a server event, the code will be run whenever that event triggers.

For example, the code in a Method that is attached to an onBeforeUpdate server event of the Part ItemType will run everytime that a Part item is updated by a user.

As in your use case, sometimes it is helpful to break the code down into multiple functions when you have a lot of logic being run in a single server event. As you found, you can include additional functions within a Method item by first closing the primary code with a closing bracket &amp;#39;}&amp;#39; and leaving the closing bracket off of the last helper function you define as seen in the example below.

&lt;pre&gt;&lt;code&gt;Innovator inn = this.getInnovator();

Item res = helperFunction(this);
Item secRes = secondHelperFunction(this);
Item lastRes = lastHelperFunction(this);

return this;
}

public Item helperFunction(Item arg) {
// Helper code
return arg;
}

public Item secondHelperFunction(Item arg) {
// Helper code
return arg;
}

public Item lastHelperFunction(Item arg) {
// Helper code
return arg;&lt;/code&gt;&lt;/pre&gt;


In order to get the function in your example to run, you should include a call to it before the first closing bracket:

&lt;pre&gt;&lt;code&gt;main();
return this; }
public Item main()
{
Innovator inn = this.getInnovator();
etc.&lt;/code&gt;&lt;/pre&gt;


Chris

____________________________________

Christopher Gillis

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