public class Record
extends Object
Record
represents a Record data.
A value of any field in a record can be obtained by getFieldValue(String)
with its
field code, except for "$id" and "$revision" fields. These fields are decoded specially into
dedicated data and can be obtained by getId()
and getRevision()
each.
getFieldValue(String)
returns implementation classes of FieldValue
, which
wrap the actual field value of String
, BigDecimal
and etc into a class depending
on the field type. For the convenience, get{FIELD_TYPE}FieldValue(String)
methods, such
as getSingleLineTextFieldValue(String)
, allow you to directly get unwrapped values.
With GET Records API, retrieved records might not contain all the fields of the App. This REST
API returns the fields only specified in "fields" request parameter if it specified. Therefore,
the corresponding Record
objects also has only the specified fields. If "$id" and
"$revision" is not specified in "fields" parameter, getId()
and getRevision()
will be return null, respectively.
List<Record> records = client.record().getRecords(app, Arrays.asList("field1"), 1, 0);
records.get(0).getFieldValue("field1"); // returns the value of "field1"
records.get(0).getId(); // will be null, the response only contains the value of "field1"
records.get(0).getFieldValue("field2"); // also, null
Record()
and putField(String, FieldValue)
.
// Creates a record object
Record record = new Record();
// "number" and "text" are the field codes of the Number and Text field, respectively.
record.putField("number", new NumberFieldValue(30));
record.putField("text", new SingleLineTextFieldValue("Hello"));
You can also create the record object from a retrieved record. In such a case, you may use newFrom(Record)
to create the object.
// Gets a record
Record record = client.record().getRecord(1, 100);
// Creates new Record object from the retrieved record,
// copying without built-in fields, namely Record Number and Created date and time.
Record copiedRecord = Record.newFrom(record);
// Adds the record
long recordId = client.record().addRecord(1, copiedRecord);
Retrieved records may contain some built-in fields that will cause errors when sent them as is to
add or update records. newFrom(Record)
create a new record object from the source record
without built-in fields to prevent those errors.
Note that Kintone only allows to set the value of some built-in field (specifically, Creator, Modifier, and Created or Updated date-time field) when adding a new record as an administrator of the App.
Constructor and Description |
---|
Record()
Constructor for creating or updating a record.
|
Record(Long id,
Long revision)
Constructor to set the ID and revision data.
|
Modifier and Type | Method and Description |
---|---|
String |
getCalcFieldValue(String fieldCode)
Returns the value of a Calculated field.
|
List<String> |
getCategoryFieldValue()
Returns the value of the Category field.
|
List<String> |
getCheckBoxFieldValue(String fieldCode)
Returns the value of a Checkbox field.
|
ZonedDateTime |
getCreatedTimeFieldValue()
Returns the value of the Created date-time field.
|
User |
getCreatorFieldValue()
Returns the value of the Creator field.
|
LocalDate |
getDateFieldValue(String fieldCode)
Returns the value of a Date field.
|
ZonedDateTime |
getDateTimeFieldValue(String fieldCode)
Returns the value of a Date and time field.
|
String |
getDropDownFieldValue(String fieldCode)
Returns the value of a Drop-down field.
|
Set<String> |
getFieldCodes(boolean includeBuiltins)
Returns field codes stored in the record object.
|
FieldType |
getFieldType(String fieldCode)
Returns the field type of the field.
|
FieldValue |
getFieldValue(String fieldCode)
Returns the value of the specified field.
|
List<FileBody> |
getFileFieldValue(String fieldCode)
Returns the value of an Attachment field.
|
List<Group> |
getGroupSelectFieldValue(String fieldCode)
Returns the value of a Group Selection field.
|
Long |
getId()
Returns the record ID.
|
String |
getLinkFieldValue(String fieldCode)
Returns the value of a Link field.
|
User |
getModifierFieldValue()
Returns the value of the Modifier field.
|
String |
getMultiLineTextFieldValue(String fieldCode)
Returns the value of a Text Area field.
|
List<String> |
getMultiSelectFieldValue(String fieldCode)
Returns the value of a Multi-choice field.
|
BigDecimal |
getNumberFieldValue(String fieldCode)
Returns the value of a Number field.
|
List<Organization> |
getOrganizationSelectFieldValue(String fieldCode)
Returns the value of a Department Selection field.
|
String |
getRadioButtonFieldValue(String fieldCode)
Returns the value of a Radio button field.
|
String |
getRecordNumberFieldValue()
Returns the value of the Record number field.
|
Long |
getRevision()
Returns the record revision.
|
String |
getRichTextFieldValue(String fieldCode)
Returns the value of a Rich text field.
|
String |
getSingleLineTextFieldValue(String fieldCode)
Returns the value of a Text field.
|
List<User> |
getStatusAssigneeFieldValue()
Returns the value of the Assignee of the Process management status field.
|
String |
getStatusFieldValue()
Returns the value of the Process management status field.
|
List<TableRow> |
getSubtableFieldValue(String fieldCode)
Returns the value of a Table.
|
LocalTime |
getTimeFieldValue(String fieldCode)
Returns the value of a Time field.
|
ZonedDateTime |
getUpdatedTimeFieldValue()
Returns the value of the Updated date-time field.
|
List<User> |
getUserSelectFieldValue(String fieldCode)
Returns the value of a User Selection field.
|
static Record |
newFrom(Record src)
Copies a record without built-in fields.
|
Record |
putField(String fieldCode,
FieldValue value)
Set the value of a field.
|
Record |
removeField(String fieldCode)
Remove a field from the record object.
|
public Record()
getId()
and getRevision()
will return
null.public Record(Long id, Long revision)
Record()
.id
- the record IDrevision
- the revision of the recordpublic static Record newFrom(Record src)
src
- the source recordsrc
public Long getId()
public Long getRevision()
public Record putField(String fieldCode, FieldValue value)
fieldCode
- the field codevalue
- the value of the fieldpublic Record removeField(String fieldCode)
fieldCode
- the field codepublic FieldValue getFieldValue(String fieldCode)
fieldCode
- the field codepublic Set<String> getFieldCodes(boolean includeBuiltins)
includeBuiltins
- true to include field code of built-in fields, false to get only non
built-in fields. "$id" and "$revision" are not included in either case.public FieldType getFieldType(String fieldCode)
fieldCode
- the field codepublic String getSingleLineTextFieldValue(String fieldCode)
fieldCode
- the field codepublic List<TableRow> getSubtableFieldValue(String fieldCode)
fieldCode
- the field codepublic String getLinkFieldValue(String fieldCode)
fieldCode
- the field codepublic List<Group> getGroupSelectFieldValue(String fieldCode)
fieldCode
- the field codepublic List<String> getMultiSelectFieldValue(String fieldCode)
fieldCode
- the field codepublic String getRadioButtonFieldValue(String fieldCode)
fieldCode
- the field codepublic LocalDate getDateFieldValue(String fieldCode)
fieldCode
- the field codepublic List<Organization> getOrganizationSelectFieldValue(String fieldCode)
fieldCode
- the field codepublic ZonedDateTime getDateTimeFieldValue(String fieldCode)
fieldCode
- the field codepublic List<User> getUserSelectFieldValue(String fieldCode)
fieldCode
- the field codepublic List<String> getCheckBoxFieldValue(String fieldCode)
fieldCode
- the field codepublic String getCalcFieldValue(String fieldCode)
fieldCode
- the field codepublic LocalTime getTimeFieldValue(String fieldCode)
fieldCode
- the field codepublic BigDecimal getNumberFieldValue(String fieldCode)
fieldCode
- the field codepublic String getDropDownFieldValue(String fieldCode)
fieldCode
- the field codepublic String getMultiLineTextFieldValue(String fieldCode)
fieldCode
- the field codepublic String getRichTextFieldValue(String fieldCode)
fieldCode
- the field codepublic List<FileBody> getFileFieldValue(String fieldCode)
fieldCode
- the field codepublic List<String> getCategoryFieldValue()
public ZonedDateTime getCreatedTimeFieldValue()
public User getCreatorFieldValue()
public User getModifierFieldValue()
public String getRecordNumberFieldValue()
public String getStatusFieldValue()
public List<User> getStatusAssigneeFieldValue()
public ZonedDateTime getUpdatedTimeFieldValue()