<?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>Reuse Code in C# Method</title><link>https://www.aras.com/community/f/development/36438/reuse-code-in-c-method</link><description>Good day all. I am trying to use a variant on my previously posted Workflow Process Get Change ItemType . I want to reuse some of the code multiple times without having to write it out every time. The code references identId, but I can&amp;#39;t figure out how</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: Reuse Code in C# Method</title><link>https://www.aras.com/community/thread/6617?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 13:08:03 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:0282a099-a5e2-4a4f-b3e9-93f17f61cf00</guid><dc:creator>Nathan H.</dc:creator><description>&lt;p&gt;AngelIp,&lt;/p&gt;
&lt;p&gt;In this case I have several Identities that I want to add based on a couple of factors, System field and Activity.&amp;nbsp; I would like to be able to use the same method for several activities if possible.&amp;nbsp; I have named strings that contain the Identity ID and use a Union to combine a couple of them for the assignment.&amp;nbsp; Because I want to use this in a few places, I want to be able to set the var identId and then move to the posted code.&amp;nbsp; I can make it work by having If statements with var identId (with the Identity IDs associated) and the code inside of the If statement, but that means I have to continually paste the code into all of the If statements.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reuse Code in C# Method</title><link>https://www.aras.com/community/thread/6614?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 10:22:52 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:9c2b237b-3846-42dd-b387-c84f1c8abc5d</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Really funny! I worked on an exact same scenario yesterday. Just look at my reviewer fields in this post:&lt;/p&gt;
&lt;p&gt;&lt;a href="/f/development/36437/what-is-the-easiest-way-to-show-a-placeholder-when-an-item-selector-is-empty"&gt;https://community.aras.com/f/development/36437/what-is-the-easiest-way-to-show-a-placeholder-when-an-item-selector-is-empty&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also thought about make this one reusable, cause I already have three similar Methods. But in my case all my CM processes have their special scnearious, so I sticked to the copy&amp;amp;paste version.&lt;/p&gt;
&lt;p&gt;In my case the line of code with your &amp;quot;identId&amp;quot; looks like this:&lt;/p&gt;
&lt;p&gt;assignment.setProperty(&amp;quot;voting_weight&amp;quot;, (100 / reviewers.Count + 1).ToString());&lt;/p&gt;
&lt;p&gt;&amp;quot;reviewers&amp;quot; in my case is a list that contains my reviewers. I use some extra code (hashset) to avoid people assign themselves multiple times to speed up the progress. It&amp;acute;s based on the available reviewer fields in the form. Do you always have the same amount of reviewers or do they change? Then you can just use a static value in side the method.&lt;/p&gt;
&lt;p&gt;You basically have to count your reviewer fields to calculate&amp;nbsp;the voting_weight. But you can also make this one dynamic based on your Team roles.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>