After you create a RecordType object, you can associate it with a RecordInfo object by calling the allocateRecordType method on a RecordInfo object and passing in the RecordType object.
//Associates a RecordType object with a RecordInfo object
public void associateRecordType(RecordInfo aoRecordInfo, RecordType aoRecordType)
{
aoRecordInfo.allocateRecordType (aoRecordType);
}
//Associates the RecordType object with the RecordInfo object using the setProperties method
public void associateRecordType(RecordInfo aoRecordInfo, RecordType aoRecordType)
{
Properties loProperties = ObjectFactory.getProperties();
Property loRTProperty = ObjectFactory.getProperty(RMProperty.ASSOCIATED_RECORDTYPE);
// Always use the thisBaseObject method while setting any object-valued property.
// For example, set the object-valued property, and with RecordType
// that is a custom object
loRTProperty.setValue(aoRecordType.thisBaseObject());
loProperties.add(loRTProperty);
aoRecordInfo.setProperties(loProperties);
}
Besides these two methods, you can also associate a RecordType object with a record at the time of record declaration by passing the RecordType property in properties collection.