ClearData([ForceClearReferences: Boolean = False]);
ForceClearReferences. Optional parameter in Fore. It determines whether elements are to be force deleted if there are links to them in related dictionaries.
The ClearData method clears all the elements from an MDM dictionary.
The method is executed taking into account the ForceClearReferences parameter. Available parameter values:
True. The elements linked with the related dictionaries are force deleted from the dictionary.
False. All unlinked elements are deleted from the dictionary. If there are elements, to which the elements from the related dictionaries refer, the exception is thrown. The False value is used in Fore by default.
NOTE. The elements are deleted without taking into account the parameters of opening the dictionary. To open the dictionary with the parameters, use the IMetabaseObjectDescriptor.Open method.
Executing the example requires the repository that contains an MDM repository with the MDM identifier containing an MDM dictionary with the MDM_DICT identifier.
Add links to the Metabase, Rds system assemblies.
Sub UserClearDict;
Var
MB: IMetabase;
MDMObj: IMetabaseObjectDescriptor;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
Begin
MB := MetabaseClass.Active;
// Get MDM repository
MDMObj := MB.ItemById("MDM");
// Get MDM dictionary
Dict := MB.ItemByIdNamespace("MDM_DICT", MDMObj.Key).Bind As IRdsDictionary;
// Open dictionary
DictInst := Dict.Open(Null);
// Delete all elements
DictInst.ClearData(True);
End Sub UserClearDict;
After executing the example all elements are deleted from the MDM_DICT dictionary.
See also: