Delete(Where: IMbElementDependentTemplate);
Where. Template, according to which delete is done.
The Delete method deletes dependencies corresponding to the specified template.
To check whether there are dependencies of MDM dictionary elements from repository objects, use the IMbElementDependentsDatabase.Exists method.
Executing the example requires MDM dictionaries with the DICT and DICT1 identifiers.
Add links to the Metabase, Rds and Ui system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Obj, Dictionary: IMetabaseObjectDescriptor;
RdsDictIns: IRdsDictionaryInstance;
Elements: IRdsDictionaryElements;
Template: IMbElementDependentTemplate;
ObjKeys: Array[2] Of Integer;
DictKey: Integer;
ElemDependDB: IMbElementDependentsDatabase;
b: Boolean;
Begin
MB := MetabaseClass.Active;
Obj := MB.ItemById("DICT1");
Dictionary := MB.ItemById("DICT");
RdsDictIns := Dictionary.Open(Null) As IRdsDictionaryInstance;
Elements := RdsDictIns.Elements;
// Object settings:
Obj := Obj.EditDescriptor;
Obj.ElementDependenciesTrackingType := MbElementDependenciesTrackingType.Dependecies;
Obj.SaveDescriptor;
// Template:
DictKey := Dictionary.Key;
Template := New MbElementDependentTemplateClass.CreateByDictionary(DictKey);
Template.ObjectKey := Dictionary.Key;
ObjKeys[0] := Elements.Element(1);
ObjKeys[1] := Elements.Element(2);
// Specify element keys
Template.ObjectKeys := ObjKeys;
// Working with dependencies:
ElemDependDB := Mb.ElementDependentsDatabase;
If ElemDependDB.Exists(Template) Then
WinApplication.YesNoCancelBox(font color="#800000">"Dependencies exist. Delete dependencies from element?", b); If b Then
ElemDependDB.Delete(Template);
End If;
End If;
Debug.WriteLine("Number of repository object keys: "
+ Template.ObjectKeysCount.ToString);
End Sub UserProc;
After executing the example the console window displays the information about the number of repository object keys. If there are dependencies that correspond to the specified template, it is prompted to delete them. If the user presses the OK button, dependencies will be deleted.
See also: