HasChildren: Boolean;
HasChildren(): boolean;
The HasChildren method returns the sign of existence of the child objects of the current objects.
Available values:
True. The object has child objects (they can be accessed in the Children property), and the objects, for which the indicator of deferred loading of descriptions is set (they can be accessed by using the IMetabase.FetchItem, IMetabase.FetchItemById, IMetabase.FetchItems and IMetabase.FetchItemsById methods).
NOTE. To get accurate value of collection element (taking into account user permissions for this element), it is recommended to unload elements of the collection (Children.Count) after renaming the HasChildren method, and then get the accurate value (Children.Item(i)).
False. The object does not have child objects.
Executing the example requires an MDM repository with the NSI identifier.
Add a link to the Metabase system assembly.
Sub UserProg;
Var
MB: IMetabase;
MDesc: IMetabaseObjectDescriptor;
MDescr: IMetabaseObjectDescriptors;
i: integer;
Begin
MB := MetabaseClass.Active;
MDesc := Mb.ItemById("NSI");
MDescr := MDesc.Children;
If MDesc.HasChildren = True Then
Debug.WriteLine("Child objects:");
Debug.Indent;
For i := 0 To MDescr.Count - 1 Do
MDesc := MDescr.Item(i);
Debug.WriteLine("Name: " + MDesc.Name + "; Identifier: " + MDesc.Id);
End For;
Debug.Unindent;
Else
Debug.WriteLine("No child objects.");
End If;
End Sub UserProg;
After executing this example, if there are child objects in the specified MDM repository, their names and identifiers are displayed in the development environment console.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MDesc: IMetabaseObjectDescriptor;
MDescr: IMetabaseObjectDescriptors;
i: integer;
Begin
MB := Params.Metabase;
MDesc := Mb.ItemById["NSI"];
MDescr := MDesc.Children;
If MDesc.HasChildren() = True Then
System.Diagnostics.Debug.WriteLine("Child objects:");
System.Diagnostics.Debug.Indent();
For i := 0 To MDescr.Count - 1 Do
MDesc := MDescr.Item[i];
System.Diagnostics.Debug.WriteLine("Name: " + MDesc.Name + "; Identifier: " + MDesc.Id);
End For;
System.Diagnostics.Debug.Unindent();
Else
System.Diagnostics.Debug.WriteLine("No child objects.");
End If;
End Sub;
See also: