- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 09:35 PM
Hi,
I have a table which does not inherit from the cmdb_ci table, as it doesn't share CI characteristics.
This table has some values which will have many-to-many relationship with the cmdb_ci_server table.
Now when I try to create a new relationship type and store the relationship in the cmdb_rel_ci table, it requires both the parent and child to be a cmdb_ci type (or its subtype).
Hence, the custom table values are not searchable there.
I also want to be able to show the related values from this custom table in the server form under related lists section.
What might be the way to make this work ?
Thanks,
Saumil
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2017 09:45 PM
Hi Rusty,
Thank you for the suggestion.
Your suggestion made me search the docs and I stumbled upon the article Create a many-to-many relationship.
We can create custom m2m relationships in the table "Many to Many Definitions [sys_m2m]". It automatically creates an intermediate table to store the m2m relationships.
Saumil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2017 10:56 PM
I think you need to make the relationship in sys_relationship
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 09:08 PM
Hi Rusty,
Thank you for the reply.
I checked the sys_relationship table. After I will specify the "Applies to table" as the server table and the "Queries from table" as the custom table, I will still need to filter the custom table records from a third table which would store the many-to-many relationships.
E.g. as in the case of "VMs" out of the box relationship :
Query with :
var gr = new GlideRecord('cmdb_rel_ci');
gr.addQuery('child', parent.sys_id);
gr.addQuery('type.name', 'Virtualized by::Virtualizes');
gr.query();
var vm_ids = [];
while (gr.next())
vm_ids.push('' + gr.parent);
current.addQuery('sys_id', vm_ids);
And I can't store the many-to-many relationship records in the cmdb_rel_ci table as the custom table does not extend the cmdb_ci table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2017 09:21 PM
yes, I think you need a custom m2m table for the many to many relationship. Are you good for now? Please mark reply as helpful or correct if I have helped you in any way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2017 09:45 PM
Hi Rusty,
Thank you for the suggestion.
Your suggestion made me search the docs and I stumbled upon the article Create a many-to-many relationship.
We can create custom m2m relationships in the table "Many to Many Definitions [sys_m2m]". It automatically creates an intermediate table to store the m2m relationships.
Saumil