Forum Discussion
We did not add any server events on any types, the OOTB events already exist on our Poly type.
Is there anything else we need to do?
Hi,
Just to make sure I understand correctly:
- You trigger an Action.
- The Action calls a server Method.
- The Method adds an ItemType as a Poly Source to your Poly ItemType.
If that's the case, a few things come to mind.
First, adding an ItemType to the Poly Sources relationship programmatically does not necessarily execute all of the logic that is triggered when the same operation is performed through the standard ItemType editor.
Some server events or internal framework logic may be skipped, which can lead to unexpected results even though the resulting database records appear identical.
May I ask what the purpose is behind having an action for administrators to add ItemTypes as Poly Sources?
For example, is the method also creating properties, relationships, or other configuration that links the Poly ItemType to the newly added source ItemType?
As you may know, properties defined on a Poly ItemType are expected to be available on the ItemTypes used as Poly Sources. Is your method also creating or validating those properties? If that logic is normally performed when configuring the Poly Source manually, it may be getting skipped when the relationship is created programmatically.
Regarding the "Restricted" entries, from my experience the most common causes are:
- The current user does not have permission to discover or get the referenced item.
- The related item cannot be resolved correctly, even though the relationship record exists (for example, an incorrect related_id).
Since you mentioned that the database entries are identical and that assigning World permissions did not help, I would investigate whether an additional metadata refresh, cache refresh, or server restart is required after adding the Poly Source relationship programmatically.
If you manually add the same ItemType as a Poly Source, save it, and then compare the resulting records (including any related metadata tables) with the programmatically created version, do you see any differences at all?
- srmorrisonearthlink-net20 days agoCreator I
Hello Sudhir,
One thing that has not been mentioned is a detail that Angela P. point out some years ago and is critical to a PolyItem. It's data is retieved via a View. So, as you add Itemtypes to a PolyItem a View is also updated.
For example, Here is the data model for xClass: Lets focus on xClassificableItem_xClass
Here is the SQL Server View for xClassificableItem_xClass:
So, be sure that the View is being updated.
You can Check by going to Views in SSMS ..... xClassificableItem_xClass ...... DesignGood Luck
Scott- sudhir_sbevision_com19 days agoCreator I
Interesting, thank you, let me check this.
- sudhir_sbevision_com18 days agoCreator I
So, we found a view corresponding to the Poly Item, we see whenever we add a new Item type it is updated which is something our code doesn't seem to be doing.
We need to figure out how to trigger that before or after add methods.
Thanks for the reply.
- sudhir_sbevision_com18 days agoCreator I
I found a workaround, everything works now, thanks
- angela16 days agoCatalyst II
Quote: "Angela P. point out some years ago and is critical to a PolyItem. It's data is retieved via a View."
Hahaha I totally forgot this one! Thanks Scott for the comment! Brought a big smile on my face!
- sudhir_sbevision_com19 days agoCreator I
Your understanding is correct.
First, adding an ItemType to the Poly Sources relationship programmatically does not necessarily execute all of the logic that is triggered when the same operation is performed through the standard ItemType editor.
This is what we think as well, we compare the DB before and after adding a type manually and through our method, and only difference we saw was the Type not being added to the "List", everything else was identical
I would investigate whether an additional metadata refresh, cache refresh
Any idea if this can be done programmatically :)
If you manually add the same ItemType as a Poly Source, save it, and then compare the resulting records (including any related metadata tables) with the programmatically created version, do you see any differences at all?
Only 2 tables were altered (in terms of row count), the Morphae (adding relation for new Type) and the Values (List values)
Since adding a Morphae relation doesn't add item to list, that part was missing from our programmatic approach.We have tried adding the type to the list as well but we still see the same Restricted