Forum Discussion
Hi Jan,
I personally would rename them, cause I like standardized naming of properties. But I understand the argument that you don´t want to touch too many Methods.
I assume the way PolyItems are built is a core feature, so we probably cannot directly influence it.
Some more technical approaches (not tested!!!):
Poly-ItemTypes are not real physical ItemTypes/tables. They are just SQL Functions that do a UNION of the various tables.
Idea #1: Change the function in SQL directly.... Ok, I am not sure if it´s possible at all. And of course it´s a modification that is overwritten all the time when you edit the ItemType. And it´s not visible for the Aras update team so if you don´t overwrite it, they definitely will. It´s not the best idea to be honest.
Idea #2: Make a custom SQL view and link it to your target ItemType via "onGet" server Method.
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 inconsistency. Regular Items often use the "name" property, while everything related to CM use "title" as naming field. Building PolyItems with these kind of ItemTypes creates exactly the problem you described.
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:
SELECT TOP(10) item_number, name from innovator.Part
UNION
SELECT TOP(10) item_number, title from innovator.EXPRESS_ECO
But as mentioned before, there are maybe better solutions out there. Maybe the "Morphae" ItemType contains some secrets that we haven´t discovered yet, not sure. There is also this TechTip which maybe helps: https://community.aras.com/b/english/posts/tech-tip-sync-a-poly-itemtype-s-properties-with-its-poly-sources
Angela
- AngelaIp3 years agoIdeator I
Edit: The SQL approach will of course eliminate the permission model if you don´t include it into the SQL query by yourself. So it´s not the most secure variant.
You mentioned an onAfterGet approach. It´s not unlikely that some approach with onGet/onBefore/onAfterGet can work. Hope anyone knows more :).
- Jan_Cvek3 years agoIdeator I
Hi Angela,
Thanks for quick answer. As you mentioned I was hoping on some secret way of achieve this :D
Anyway I have an itemtype with onGet method implemented which call SQL stored procedure (to accept parameters for filtration) and it works.
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.
I'm looking for more elegant way... with more configuration and less coding...
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.
- AngelaIp3 years agoIdeator I
Hi Jan,
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´s still would require a lot of coding.
Do you use a custom onGet Method or the Aras Federation sample?
I remember I still have this open post in this forum:
I use both version (custom and Aras) in parallel and both have their pros and cons. The Aras Federation sample contains a mapping ItemType so it´s faster to implement and doesn´t require custom code. But query speed is higher with the custom variant.
- Calvin_Hernandez3 years agoIdeator I
I know this is an old thread, but this might help someone else. Here's a server method I created recently to accomplish something similar.
For the poly item and all the poly sources, I created a property called "item_number", and then just copied the value of the property I wanted to use into the "item_number" property after a new item is created. You can do this for any number of properties you need to use for the poly item.
You can also get creative and do this retroactively on existing items, which I had to do as well.
You'll also notice I use fake properties to keep other server events from firing recursively.
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:f4b6e6ac-db45-46fd-869f-d5ca29cd2d30:type=csharp&text=%2F%2F%20Method%20name%3A%20op_SetItemNumberProperty%0A%2F%2F%20Created%20on%3A%20%2010%2F2%2F23%0A%2F%2F%20Created%20by%3A%20%20CJ%20Hernandez%0A%20%20%20%20%2F%2F%20rev_0%3A%20Updates%20the%20%22item_number%22%20property%20for%20poly%20sources%0A%0A%0AInnovator%20inn%20%3D%20this.getInnovator%28%29%3B%0AItem%20itm%20%3D%20this%3B%0Astring%20property_to_copy%20%3D%20this.getProperty%28%22copy_me%22%2C%22%22%29%3B%0Aif%28property_to_copy%20%21%3D%20%22%22%29%20%7B%0A%20%20%20%20itm.setAttribute%28%22action%22%2C%22edit%22%29%3B%0A%20%20%20%20string%20item_number%20%3D%20this.getProperty%28property_to_copy%2C%22%22%29%3B%0A%20%20%20%20itm.setProperty%28%22item_number%22%2Citem_number%29%3B%0A%20%20%20%20%0A%20%20%20%20%2F%2FAdd%20fake%20property%20to%20keep%20other%20events%20from%20firing%0A%20%20%20%20itm.setProperty%28%22ignore_this%22%2C%221%22%29%3B%0A%20%20%20%20%0A%20%20%20%20Item%20result%20%3D%20itm.apply%28%29%3B%0A%20%20%20%20if%28result.isError%28%29%29%0A%20%20%20%20%20%20%20%20return%20inn.newError%28result.getErrorCode%28%29%20%2B%20%22%3A%20%22%20%2B%20result.getErrorDetail%28%29%29%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20return%20result%3B%0A%7D%0Aelse%0A%20%20%20%20return%20inn.newError%28%22Could%20not%20read%20property%20value%20to%20copy.%22%29%3B]
I call it from an onAfterAdd server method like this:
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:ee0fa1af-8697-47c1-bb5a-feb2c4a6c7d8:type=csharp&text=Item%20itm%20%3D%20this%3B%0A%0Aitm.setAttribute%28%22action%22%2C%22op_SetItemNumberProperty%22%29%3B%0Aitm.setProperty%28%22copy_me%22%2C%5BNAME%20OF%20PROPERTY%20TO%20COPY%5D%29%3B%0Aitm.apply%28%29%3B%0A%0A%2F%2FInsert%20error%20checking%20here%0Areturn%20itm%3B]
Hope this helps!