<?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>Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/f/development/37631/poly-itemtype---mapping-properties-of-poly-sources</link><description>Hi, 
 We have more and more needs to display tables with several different itemtypes in one place with all filtering features and of course the first thought is to use poly itemtype. 
 
 But here is the problem. Let say that we have 4 poly sources which</description><dc:language>ja-JP</dc:language><generator>Telligent Community 12</generator><item><title>RE: Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/thread/9684?ContentTypeID=1</link><pubDate>Tue, 03 Oct 2023 09:35:12 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:0229f531-3263-405f-a2d0-8999715354d0</guid><dc:creator>Calvin Hernandez</dc:creator><description>&lt;p&gt;I know this is an old thread, but this might help someone else. Here&amp;#39;s a server method I created recently to accomplish something similar.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the poly item and all the poly sources, I created a property called &amp;quot;item_number&amp;quot;, and then just copied the value of the property I wanted to use&amp;nbsp;into the &amp;quot;item_number&amp;quot; property after a new item is created. You can do this for any number of properties you need to use for the poly item.&lt;/p&gt;
&lt;p&gt;You can also get creative and do this retroactively on existing items, which I had to do as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You&amp;#39;ll also notice I use &lt;a href="/community/b/english/posts/tech-tip-utilizing-fake-properties" rel="noopener noreferrer" target="_blank"&gt;fake properties&lt;/a&gt; to keep other server events from firing recursively.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;// Method name: op_SetItemNumberProperty
// Created on:  10/2/23
// Created by:  CJ Hernandez
    // rev_0: Updates the &amp;quot;item_number&amp;quot; property for poly sources


Innovator inn = this.getInnovator();
Item itm = this;
string property_to_copy = this.getProperty(&amp;quot;copy_me&amp;quot;,&amp;quot;&amp;quot;);
if(property_to_copy != &amp;quot;&amp;quot;) {
    itm.setAttribute(&amp;quot;action&amp;quot;,&amp;quot;edit&amp;quot;);
    string item_number = this.getProperty(property_to_copy,&amp;quot;&amp;quot;);
    itm.setProperty(&amp;quot;item_number&amp;quot;,item_number);
    
    //Add fake property to keep other events from firing
    itm.setProperty(&amp;quot;ignore_this&amp;quot;,&amp;quot;1&amp;quot;);
    
    Item result = itm.apply();
    if(result.isError())
        return inn.newError(result.getErrorCode() + &amp;quot;: &amp;quot; + result.getErrorDetail());
    else
        return result;
}
else
    return inn.newError(&amp;quot;Could not read property value to copy.&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I call it from an onAfterAdd server method like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;Item itm = this;

itm.setAttribute(&amp;quot;action&amp;quot;,&amp;quot;op_SetItemNumberProperty&amp;quot;);
itm.setProperty(&amp;quot;copy_me&amp;quot;,[NAME OF PROPERTY TO COPY]);
itm.apply();

//Insert error checking here
return itm;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/thread/8836?ContentTypeID=1</link><pubDate>Fri, 07 Oct 2022 10:03:47 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:bb74c067-bc9b-4229-9bc7-38502dc56c0f</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Jan,&lt;/p&gt;
&lt;p&gt;I agree, somekind of mapping logic would be the best solution. Even if you merge two or more ItemTypes inside an onBefore/AfterGet Method, it&amp;acute;s still would require a lot of coding.&lt;/p&gt;
&lt;p&gt;Do you use a custom onGet Method or the Aras Federation sample?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;remember I still have this open post in this forum:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.aras.com/f/applications/36935/who-is-using-the-aras-sql-federation-itemtype-sample-v3-1-and-can-share-experience"&gt;community.aras.com/.../who-is-using-the-aras-sql-federation-itemtype-sample-v3-1-and-can-share-experience&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I use both version (custom and Aras) in parallel and both have their pros and cons.&amp;nbsp;The Aras Federation sample contains a mapping ItemType so it&amp;acute;s faster to implement and doesn&amp;acute;t require custom code. But query speed is higher with the custom variant.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/thread/8831?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 18:40:16 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:99f6074e-9e47-4557-9802-2345c31fff31</guid><dc:creator>Jan Cvek - Akrapovic</dc:creator><description>&lt;p&gt;Hi Angela,&lt;/p&gt;
&lt;p&gt;Thanks for quick answer. As you mentioned I was hoping on some secret way of achieve this :D&lt;/p&gt;
&lt;p&gt;Anyway I have an itemtype with onGet method implemented which call SQL stored procedure (to accept parameters for filtration) and it works.&lt;/p&gt;
&lt;p&gt;But... to cover all possible combination of filtration (like, not like, equal...) and all type of properties (string, date, list...) for every column takes a lot of work and nerves.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m looking for more elegant way... with more configuration and less coding...&lt;/p&gt;
&lt;p&gt;Maybe Aras only need to implement some mapping logic between poly source properties (maybe also some conversion logic...) and poly itemtype would be way more useful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/thread/8830?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 14:01:46 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:719c966a-d91c-45a8-8dcd-dbad800f8ded</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Edit: The SQL approach will of course eliminate the permission model if you don&amp;acute;t include it into the SQL query by yourself. So it&amp;acute;s not the most secure variant.&lt;/p&gt;
&lt;p&gt;You mentioned an onAfterGet approach. It&amp;acute;s not unlikely that some approach with onGet/onBefore/onAfterGet can work. Hope anyone knows more :).&lt;/p&gt;
&lt;p&gt;&lt;a href="/f/development/3496/how-to-create-a-new-part-toc-menu-item-that-does-a-custom-search"&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Poly ItemType - mapping properties of poly sources</title><link>https://www.aras.com/community/thread/8829?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 13:39:22 GMT</pubDate><guid isPermaLink="false">916d3f7e-8ddc-42f8-8d45-380822f51406:dc70efa6-ae40-48bf-ad12-ce04d57d060e</guid><dc:creator>AngelaIp</dc:creator><description>&lt;p&gt;Hi Jan,&lt;/p&gt;
&lt;p&gt;I personally would rename them, cause I like standardized naming of properties. But I understand the argument that you don&amp;acute;t want to touch too many Methods.&lt;br /&gt;I assume the way PolyItems are built is a core feature, so we probably cannot&amp;nbsp;directly influence it.&lt;/p&gt;
&lt;p&gt;Some more technical approaches (not tested!!!):&lt;/p&gt;
&lt;p&gt;Poly-ItemTypes are not real physical ItemTypes/tables. They are just SQL Functions that do a UNION of the various tables.&lt;/p&gt;
&lt;p&gt;Idea #1: Change the function in SQL directly.... Ok, I am not sure if it&amp;acute;s possible at all. And of course it&amp;acute;s a modification that is overwritten all the time when you edit the ItemType. And it&amp;acute;s not visible for the Aras update team so&amp;nbsp;if you don&amp;acute;t overwrite it, they definitely will. It&amp;acute;s not the best idea to be honest.&lt;/p&gt;
&lt;p&gt;Idea #2: Make a custom SQL view and link it to your target ItemType via &amp;quot;onGet&amp;quot; server Method.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;These ideas shall not be seen as final answers. I am also interested in this question! One of design mistakes of the early days of innovator was the name/title &lt;span&gt;inconsistency. Regular Items often use the &amp;quot;name&amp;quot; property, while everything related to CM use &amp;quot;title&amp;quot; as naming field. Building PolyItems with these kind of ItemTypes creates exactly the problem you described.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;Out of interest I made a quick SQL test by myself, and indeed a custom SQL call for the Poly could be used to link non-identical property names:&lt;/p&gt;
&lt;p&gt;SELECT TOP(10) item_number, name from innovator.Part&lt;br /&gt;UNION&lt;br /&gt;SELECT TOP(10) item_number, title from innovator.EXPRESS_ECO&lt;/p&gt;
&lt;p&gt;But as mentioned before, there are maybe better solutions out there. Maybe the &amp;quot;Morphae&amp;quot; ItemType contains some secrets that we haven&amp;acute;t discovered yet, not sure. There is also this TechTip which maybe helps:&amp;nbsp;&lt;a href="/b/english/posts/tech-tip-sync-a-poly-itemtype-s-properties-with-its-poly-sources"&gt;https://community.aras.com/b/english/posts/tech-tip-sync-a-poly-itemtype-s-properties-with-its-poly-sources&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Angela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>