AddWithOwner(Object: IMetabaseObjectDescriptor; Owner: IMetabaseObjectDescriptor): IMetabaseCustomObjectReference;
Object. Repository object, on which custom class object depends.
Owner. Repository object that is a parent for the object specified in the Object parameter.
The AddWithOwner method adds dependency from object and its parent.
To add dependency only from object, use the IMetabaseCustomObjectReferences.Add method.
Executing the example requires that the repository contains a custom class object with the CUSTOM_CLASS_OBJ identifier, an object with the MDM_HIE_INDICATOR_D identifier that is a child object for object with the MDM_INDICATOR_D identifier.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
pMb: IMetabase;
pObject: IMetabaseObject;
pCustomObject: IMetabaseCustomObject;
pWriter: IMetabaseCustomObjectWriter;
pReferences: IMetabaseCustomObjectReferences;
pRef: IMetabaseCustomObjectReference;
Begin
// Get the current repository
pMb := MetabaseClass.Active;
// Get custom class object
pObject := pMb.ItemById("CUSTOM_CLASS_OBJ").Edit;
pCustomObject := pObject As IMetabaseCustomObject;
// Create an object that enables writing data to custom class object
pWriter := pCustomObject.CreateWriter;
// Get collection of object dependencies
pReferences := pWriter.References;
// Clear collection of object dependencies
pReferences.Clear;
// Add the MDM_HIE_INDICATOR_D object with its parent MDM_INDICATOR_D
pRef := pReferences.AddWithOwner(pMb.ItemById("MDM_HIE_INDICATOR_D"), pMb.ItemById("MDM_INDICATOR_D"));
// Output information about this to console window
Debug.WriteLine("Object '" + pRef.Object.Id + "' with parent '" + pRef.Owner.Id + "' are added");
// Save changes
pWriter.Save;
pObject.Save;
End Sub UserProc;
After executing the example the dependency from the MDM_HIE_INDICATOR_D object and its parent is added for custom class object.
See also: