Jump to: navigation, search

Changes


HowTo:Relate Objects

2,103 bytes added, 18:34, 3 December 2019
* Use [[Reference|References]] to build up an '''1:n''' relationship between two instances of an entity
Which method fits best can not be predicted and clearly depends on the use case and the data model.  == Connect objects via Reference == If you want one or multiple objects to refer to a single target object each, a reference is what you need. You can either ask an object about the one it refers to, or ask a target object about all objects referring to it via a reference. This is useful, if you want to connect objects but there is no necessity for '''both''' "sides" to be connected to multiple other objects. In this case, an object's property contains a link to the target object (respectively, its UID). Let's call the target object '''B''' and the object referring to the target object '''A'''. '''A''' refers to '''B'''. In order to achieve this, the following requirements must be met:* The MetaClass of object '''A''' must have a respectively configured '''link''' MetaProperty. - The property type should be '''Guid'''. - A [[Reference|Reference]] object defining the target MetaClass should be set on the MetaProperty. * The property value for the link MetaProperty on object '''A''' must be set to object '''B'''. You can achieve this with the following steps:* Create a new [[Reference]] ([[HowTo:Create_a_new_Reference]]).* Set the [[MetaClass]] of '''B''' on the '''TARGETTYPE''' property of the previously created reference, as explained in the HowTo above. * Make sure there is a [[MetaProperty]] on the MetaClass of object '''A''' you can use. If necessary, create a new MetaProperty instance and relate it to the MetaClass of '''A''' via the MetaClass to MetaProperty relation ([[HowTo:Add_a_MetaProperty_to_a_MetaClass]]).* Set the previously created reference on the new MetaProperty ([[HowTo:Create_a_new_MetaProperty#REFERENCE]]).* Make sure all changes are saved.* Open the Bulk Editor for the MetaClass of '''A''' and set the property value for the new MetaProperty on '''A''' to '''B''', in one of the following ways: ** dragging and dropping object '''B''' onto the cell ** selecting the object '''B''' from the dialog appearing after double-clicking the cell * Save object '''A'''. The connection is now established and can be used, e.g., in the ACM view or by programmatic customizing.
[[Category:How-To|Relate Objects]]
1,606
edits