User Guide > Scripting > Script Objects > DJRecord Object Type
Was this helpful?
DJRecord Object Type
The DJRecord object is a container for record instances. The DJRecord and DJField objects that the object contains represent a record layout (schema). DJField objects can also serve as data containers for a record instance.
See Also
Properties
 
Property
Type
Access
Description
Integer
RO
Return the number of fields in the record object.
DJField
RO
Get a reference to a field in a record layout by name or ordinal position.
String
RW
Get/set the name of the DJRecord object.
DJRecord
RO
Return a reference to the object itself.
FieldCount Property
The FieldCount property returns an integer value with the number of fields in the record layout for a DJRecord object.
Syntax
record.FieldCount
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, which is the subject of the property or method invocation.
Example
'The following example logs the names of each field in a DJRecord object named r.
For i=1 To r.FieldCount
  LogMessage("Info","Field name " & i & ": " & r.Field(i).Name)
Next i
Fields Property
The Fields property is a container for the fields in a record layout. The property is indexed by field name or by ordinal position in the record layout.
Syntax
record.Fields(n)
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, which is the subject of the property or method invocation.
Integer or String
Yes
An expression that evaluates to a string, with the name of the field or an Integer with the position of the field in the container.
'Get a reference to the third field in the default record layout of the myImport DJImport object.
Dim f As DJField
Dim r As DJRecord
Set r = myImport.Records(1)
Set f = r.Fields(3)
Example
'Get a reference to the third field in the default record layout of the myImport DJImport object.
Dim f As DJField
Dim r As DJRecord
Set r = myImport.Records(1)
Set f = r.Fields(3)
Name Property
The Name property accesses the record type name for a DJRecord object. It is an alias for the Value property.
Syntax
record.Name
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, which is the subject of the property or method invocation.
Example
'Set the record type name for a new DJRecord object.
Dim r As DJRecord
Set r = New DJRecord
r.Name = "Detail"
Self Property
The Self property is used for getting a reference to an object that can then be passed as an argument to a function or method call. The reason for having a special property for getting the object reference is to resolve an ambiguity with the default property Name.
This is similar to the distinction between normal variable assignment (Let) the use of Set for assigning object variables. When you use a DJRecord object variable without an associated property or method, the integration language processor assumes an implied access of the Name property.
Syntax
record.Self
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, which is the subject of the property or method invocation.
Example
'The following example shows how to use the Self property for copying the contents of a DJRecord object r to the first record layout of the primary target for the map.
RecordAt("SOURCE/R1").Copy(r.self)
Methods
 
Method
Type
Description
Copy the contents of a DJRowSet record or another DJRecord object to a record layout of a DJRecord object. The clear flag indicates whether the target fields are cleared before doing the copy operation.
DJField
Append a new field to the record object. If a field reference is provided (fld), it is used as a template for data type.
Copy Method
The Copy method is used to copy data from one DJRecord object to another DJRecord object or from a record in a DJRowSet to a DJRecord object. The data is copied field by field.
If the source of the copy has more fields than the target, the copy will stop after data is copied to the last field in the target. Similarly, if the source has fewer fields than the target, the copy will stop after copying the last source field.
The clear parameter can be used to clear the target fields of data before the copy operation. The fields are cleared by initializing them with null values. This is useful for cases where the source records may have fewer fields than the target, and it is necessary to make sure that none of the old field values remain.
Syntax
record.Copy(rec, [, clear])
'OR
record.Copy(rs, n [, clear])
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, which is the subject of the property or method invocation.
DJRecord
Yes
Reference to a DJRecord object to be used as the source for the copy.
DJRowSet
Yes
Reference to a DJRowSet.
Integer
Yes
Index of the record in the DJRowSet collection to be used as the source for the copy.
Boolean
No
Flag indicating whether or not the target record contents should be cleared before the copy operation.
Exceptions
The Copy method may return one of the following exceptions if there is an error at run time.
Exception
Description
ERR_TYPEMISMATCH
Returned if any of the arguments for the method are invalid.
Example
'The follow code snippet copies field values from the source record called 1 to the first target record type:
RecordAt("/SOURCE/R1").Copy(RecordAt("/SOURCE/R1").self)
NewField Method
The NewField method allows you to append a new field to the end of the record layout for a DJRecord object. When the NewField method is called without the optional field argument, a new Text field with a length of 16 characters are appended to the end of the record layout.
The length of the Text field can be changed using the Length property of the DJField object interface. When the optional field argument is provided, it is used as a template for creating the new field. The new field is created using all of the data type information from the template. Record and field metadata, such as the field name, will not be cloned.
The NewField method returns a reference to the new DJField object.
Syntax
record.NewField([field])
Parameters
 
Type
Required
Description
DJRecord
Yes
Reference to the DJRecord, the subject of the property or method invocation.
DJField
No
Reference to a DJField object used as a template for field data type information.
Exceptions
The NewField method may return one of the following exceptions if there is an error at run time.
Exception
Description
ERR_OBJREQ
Returned if optional field parameter is not a reference to a valid DJField object.
ERR_OUTOFMEM
Returned when there is not enough memory to create a new DJField object.
ERR_ROOBJECT
Returned when there is an attempt to add a field to a read-only object.
Example
'The following example shows how to create new DJField objects for a record layout using NewField.
'Append a field to the default record object:
Dim r As DJRecord
Set r = New DJRecord
Dim fld As DJField
Set fld = r.NewField()
'Change the length of the field to 64 characters:
fld.Length = 64
fld.Name = "MyNewField"
Operators
 
Operator
Type
Description
New
DJRecord
Create a new object
New Operator
The New operator creates a new instance of a DJRecord object. The operator returns a reference to the new object. Typically, this reference is assigned to an object variable that has been declared with a compatible type. The assignment is done using the Set statement.
Syntax
New DJRecord
Example
'The following example shows how to create a new DJRecord.
Public r As DJRecord
Set r = New DJRecord
Last modified date: 08/02/2023