4.5 NWFieldDescriptions Collection

The NWFieldDescriptions collection lets you add field types to a specified layout in the NDs Schema. It allows you to manage and reference NWFieldDescription objects.You can use this object to:

4.5.1 Object Diagram

Describes the hierarchy of various objects in NWFieldDescriptions object

4.5.2 Count property

Returns the number of field description objects it contains.

Syntax

object.Count

Type

Long.

Attributes

Read-only.

Example

This example returns the number of fields in a layout.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("User", "Password")
Set Layouts = nwdir.Layouts
’ Display all the fields of user layout
Set userLayout = Layouts.Item ("User")
Set userFields = userlayout.Fields
Print "Total number of Fields in the User Layout: "&UserFields.Count

4.5.3 Reset method

Initializes the collection for the enumeration of NWFieldDescription objects.

Syntax

object.Reset()

Parameters

None.

Return Values

Void.

Example

This example returns all the NWFieldDescription objects.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("User", "Password")
Set Layouts = nwdir.Layouts
’ Display all the fields of user layout
Set userLayout = Layouts.Item ("User")
Set userFields = Userlayout.Fields
Print "Total number of Fields in the User Layout: "&userFields.Count
userFields.Reset()
While UserFields.HasMoreElements()
    Set UserField = UserFields.Next()
    Print "The user field is: "&UserField.Name 
    Print Userfield.Optional()
Wend

4.5.4 Next method

Returns the next NWFieldDescription object from the collection.

Syntax

object.Next()

Parameters

None.

Return Values

NWFieldDescription.

Example

This example returns the next NWFieldDescription object in the collection.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("user", "password")
Set Layouts = nwdir.Layouts()
’Display all the fields of user layout
Set UserLayout = Layouts.Item ("User")
Set UserFields = userlayout.Fields()
Print "Total number of Fields: "&UserFields.Count
UserFields.Reset()
While UserFields.HasMoreElements()
    Set UserField = UserFields.Next()
    Print "The name: "&UserField.Name
    Print "The field is optional: "&UserField.Optional
Wend

4.5.5 HasMoreElements method

Determines whether or not any more Entry objects exist in the collection based on the specified path.

Syntax

Object.HasMoreElements()

Parameters

None.

Return Values

Boolean.

Remarks

Returns true if the collection contains some more NWFieldDescription objects.

Example

This example returns all NWFieldDescription objects in the specified path.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("User", "Password")
Set Layouts = nwdir.Layouts()
’ Display all the fields of user layout
Set UserLayout = Layouts.Item ("User")
Set UserFields = userlayout.Fields
Print "Total number of Fields in the User Layout: "&UserFields.Count
UserFields.Reset()
While UserFields.HasMoreElements()
    Set UserField = UserFields.Next()
    Print UserField.Name
    Print UserField.Optional
Wend 

4.5.6 Element method

Returns a NWFieldDescription object for the given index.

Syntax

object.Element(
  Index As Variant)

Parameters

Index

Index can be either numeric or string. The string value represents the field name.

Return Values

NWFieldDescription.

Example

This example returns the NWFieldDescription object for the specified index.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("user", "password")
Set Layouts = nwdir.Layouts()
’ Display all the fields of user layout
Set UserLayout = Layouts.Element("User")
Set UserFields = Userlayout.Fields()
Print "Total number of Fields in the User Layout:
"&UserFields.Count
UserFields.Reset()
While UserFields.HasMoreElements()
    Set UserField = UserFields.Next()
    Print "The name is: "&UserField.Name 
    Print "The field is optional:"&UserField.Optional
Wend
Set SurnameField = UserFields.Element("SurName")
Print SurnameField.Name

4.5.7 Item method

Returns a NWFieldDescription object for the given Index.

Syntax

object.Item(
  Index As Variant)

Parameters

Index

Index can be either numeric or string. The string value represents the field name.

Return Values

NWFieldDescription.

Example

This example returns the NWFieldDescription object for the specified index.

Set nwdir=CreateObject("UCX:NWDIR")
nwdir.Login ("user","password")
Set Layouts = nwdir.Layouts()
’ Display all the fields of user layout
Set UserLayout = Layouts.Element("User")
Set UserFields = Userlayout.Fields()
Print "Total number of Fields in the User Layout:
"&UserFields.Count
UserFields.Reset()
While UserFields.HasMoreElements()
    Set UserField = UserFields.Next()
    Print "The name is: "&UserField.Name 
    Print "The field is optional:"&UserField.Optional
Wend
Set SurnameField = UserFields.Element("SurName")
Print SurnameField.Name

See Also

Element method

4.5.8 AddElement method

Adds a field to the NDS Schema.

Syntax

object.AddElement(
  FieldName As String)

Parameters

FieldName

Name of the desired field.

Return Values

NWFieldDescription.

Example

This example shows how to add an NWFieldDescription object into NDS Schema.

Set nwdir = CreateObject("UCX:NWDIR")
nwdir.Login "User", "Password"
’Create a new field type
NewFieldTypeName = "NSN FieldType"
Set FieldTypes = nwdir.FieldTypes
FieldTypes.AddElement (NewFieldTypeName, SYN_CI_STRING)
’ Add new field type into NSN Layout
Set NewLayout = nwdir.Layouts.Element("NSN Layout")
NewLayout.Fields.AddElement ("NewFieldTypeName")
If (Err.Number = 0) Then
    Print "New field is added to the Layout"
Else
    Print "Failed to new field"
End If 

4.5.9 Add method

Modifies the NDS Schema by adding a new field to the layout for which this field description object belongs.

Syntax

object.Add(
  FieldName As String)

Parameters

FieldName

Name of the desired field.

Return Values

NWFieldDescription.

Example

This example shows how to add a field into NDS Schema.

Set nwdir = CreateObject("UCX:NWDIR")
nwdir.Login "User", "Password"
’ Create a new field type
NewFieldTypeName = "NSN FieldType"
Set FieldTypes = nwdir.FieldTypes
FieldTypes.Add NewFieldTypeName, SYN_CI_STRING
’ Add new field type into NSN Layout
Set NewLayout = nwdir.Layouts.Element("NSN Layout")
NewLayout.Fields.Add ("NewFieldTypeName")
If (Err.Number = 0) Then
    Print "New field is added to the Layout"
Else
    Print "Failed to new field"
End If