<?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>How set Role and Name with default when Project is created?</title><link>https://www.aras.com/community/f/development/3970/how-set-role-and-name-with-default-when-project-is-created</link><description>Hi expert,

When new &amp;quot;Project&amp;quot; is created by saving, I need to set Role and Name in Team tab of new project as default.

For example, when a user create new project, using C#method I&amp;#39;d like to add as below:

Role&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;Name

Project</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: How set Role and Name with default when Project is created?</title><link>https://www.aras.com/community/thread/2153?ContentTypeID=1</link><pubDate>Wed, 17 Oct 2018 09:35:00 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:259a6418-1cc2-4756-8cae-06780a7638aa</guid><dc:creator>Christopher Gillis</dc:creator><description>Hello,

It doesn&amp;#39;t look like there&amp;#39;s an issue with the code provided. Could you run a search with the AML below to check the value of the &lt;strong&gt;sort_order&lt;/strong&gt; in the database?

&lt;pre&gt;&lt;code&gt;&amp;lt;AML&amp;gt;
&amp;lt;Item type=&amp;quot;Project Team&amp;quot; action=&amp;quot;get&amp;quot;&amp;gt;
&amp;lt;source_id&amp;gt;YOUR_PROJECT_ID&amp;lt;/source_id&amp;gt;
&amp;lt;/Item&amp;gt;
&amp;lt;/AML&amp;gt;&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><item><title>RE: How set Role and Name with default when Project is created?</title><link>https://www.aras.com/community/thread/2152?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2018 21:32:23 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:0f977354-d3a5-4372-9c0c-f5aabd6f87a2</guid><dc:creator>Joseph An</dc:creator><description>Hi Christopher,

Can I ask you one more thing?

When I created new project with the code below, I could see &amp;quot;Project Executive&amp;quot; and so on are added automatically.

However, I found that &amp;quot;sort order&amp;quot; doesn&amp;#39;t work.

Would you please check whether I did something wrong in the codes below? Thank you so much.

Item item_proj_exec = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
item_proj_exec.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Project Executive&amp;quot;);
item_proj_exec.setProperty(&amp;quot;sort_order&amp;quot;, &amp;quot;10&amp;quot;);
Item item_proj_exec_result = item_proj_exec.apply();

Item item_seni_supplier = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
item_seni_supplier.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Senior Supplier&amp;quot;);
item_seni_supplier.setProperty(&amp;quot;sort_order&amp;quot;, &amp;quot;20&amp;quot;);
Item item_seni_supplier_result = item_seni_supplier.apply();

Item item_seni_user = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
item_seni_user.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Senior User&amp;quot;);
item_seni_user.setProperty(&amp;quot;sort_order&amp;quot;, &amp;quot;30&amp;quot;);
Item item_seni_user_result = item_seni_user.apply();

&amp;nbsp;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How set Role and Name with default when Project is created?</title><link>https://www.aras.com/community/thread/2151?ContentTypeID=1</link><pubDate>Tue, 16 Oct 2018 16:36:10 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:beb701c8-54e4-47c8-b5c1-23c0eecad1e3</guid><dc:creator>Joseph An</dc:creator><description>Hi Christopher,

Thank you so ~~~~~ much for your reply.

Have a good day.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How set Role and Name with default when Project is created?</title><link>https://www.aras.com/community/thread/2150?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2018 16:19:52 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:e64ebb5b-509f-4f48-b39f-b02f714f4494</guid><dc:creator>Christopher Gillis</dc:creator><description>Hi Joseph,

You can accomplish this by using an &lt;strong&gt;onBeforeAdd&lt;/strong&gt; Server Event on the Project ItemType to add these relationships using code similar to the sample below.

&lt;pre&gt;&lt;code&gt;Innovator inn = this.getInnovator();
// Add a default project team whenever a Project is created
Item projectTeam = this.getRelationships(&amp;quot;Project Team&amp;quot;);
// Allow the default to be overridden if the user defines another team
if (projectTeam.getItemCount() &amp;gt;= 1)
{
return this;
}
// Add Susan
Item susan = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
susan.setProperty(&amp;quot;related_id&amp;quot;, &amp;quot;8ADEF377932547CB8684EF598BADC491&amp;quot;);
susan.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Project Executive&amp;quot;);
// Add James
Item james = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
james.setProperty(&amp;quot;related_id&amp;quot;, &amp;quot;AECB07A16E0B4D12AF4CD098C783E073&amp;quot;);
james.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Senior Supplier&amp;quot;);
// Add Phillip
Item phillip = this.createRelationship(&amp;quot;Project Team&amp;quot;, &amp;quot;add&amp;quot;);
phillip.setProperty(&amp;quot;related_id&amp;quot;, &amp;quot;561695BD17B64105AD259D37765BD769&amp;quot;);
phillip.setProperty(&amp;quot;role&amp;quot;, &amp;quot;Senior User&amp;quot;);
return this;&lt;/code&gt;&lt;/pre&gt;


I&amp;#39;ve hard-coded in the IDs of the Identities I want to add in the above example, but you could also perform a lookup based on the names of your users. Additionally, I&amp;#39;ve written this method in such a way that this team will only be added as a default if no other team members are defined before the Project is saved. You can remove the &lt;strong&gt;if&lt;/strong&gt; statement at the beginning of this sample if you wish for these team members to always be added.

Chris

&lt;hr /&gt;

Christopher Gillis

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