Record
Provide manipulate functions on records: get, update, delete, update the record status & assignees in the kintone app
Constructor
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Constructor params. |
params.connection | Connection | yes | The connection module of this SDK. |
Sample code
Init record module
const kintone = require('@kintone/kintone-wechat-miniprogram-sdk'); let kintoneRecord = new kintone.Record({connection});
Methods
getRecord(params)
Retrieves details of 1 record from an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Get record params |
params.app | Integer | yes | The kintone app ID |
params.id | Integer | yes | The record ID in kintone app |
Return
Promise
Sample code
Get record
const app = 'your_app_id'; const id = 'your_record_id'; kintoneRecord.getRecord({app, id}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
getRecords(params)
Retrieves details of multiple records from an app using a query string.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Get records params |
params.app | Integer | yes | The kintone app ID |
params.query | String | (optional) | The query string that will specify what records will be responded. |
params.fields | Array<String> | (optional) | List of field codes you want in the response. |
params.totalCount | Boolean | (optional) | If "true", the request will retrieve total count of records match with query conditions. |
Return
Promise
Sample code
Get records
const app = 'your_app_id'; const query = 'your_query_string'; const fields = [ 'your_field_code', // another fieldCode ] const totalCount = 'your_decide_true_or_false'; kintoneRecord.getRecords({app, query, fields, totalCount}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
getAllRecordsByQuery(params)
- Retrieves details of all records from an app using a query string.
- Can't indicate limit and offset of query.
- Number of records can be retrieved at once is greater than the default limitations
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Get records by query params |
params.app | Integer | yes | The kintone app ID |
params.query | String | (optional) | The query string that will specify what records will be responded. |
params.fields | Array<String> | (optional) | List of field codes you want in the response. |
params.totalCount | Boolean | (optional) | If "true", the request will retrieve total count of records match with query conditions. |
Return
Promise
Sample code
Get all records by query without limitation
const app = 'your_app_id'; const query = 'your_query_string'; const fields = [ 'your_field_code', // another fieldCode ] const totalCount = 'your_decide_true_or_false'; kintoneRecord.getAllRecordsByQuery({app, query, fields, totalCount}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
getAllRecordsByCursor(params)
- Retrieves details of all records from an app using a query string.
- Can't indicate limit and offset of query.
- Number of records can be retrieved at once is greater than the default limitations
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to create cursor |
params.app | Integer | yes | The kintone app ID |
params.query | String | (optional) | The query string that will specify what records will be responded. |
params.fields | Array<String> | (optional) | List of field codes you want in the response. |
Return
Promise
Sample code
Get all records by cursor
const rcOption = { app: 'your_app_id', fields: [ 'your_field_code', // another fieldCode ], query: 'your_query_string' }; kintoneRecord.getAllRecordsByCursor(rcOption).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
addRecord(params)
Add one record to an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to add record |
params.app | Integer | yes | The kintone app ID |
params.record | JSONObject | (optional) | The record data to be add to kintone app. About the format, please look the sample below or reference at the end of this page |
Return
Promise
Sample code
Add record
const app = 'your_app_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; kintoneRecord.addRecord({app, record}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
addRecords(params)
Add multiple records to an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to add records |
params.app | Integer | yes | The kintone app ID |
params.records | Array<JSONObject> | yes | List of records data to be add to kintone app. About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Add multi records
const app = 'your_app_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const records = [ record, // another record ]; kintoneRecord.addRecords({app, records}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
addAllRecords(params)
- Add multiple records to an app.
- Can insert over 2000 records to kintone app, but can't do rollback.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to add all record |
params.app | Integer | yes | The kintone app ID |
params.records | Array<JSONObject> | yes | List of records data to be add to kintone app. About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Add all records without limitation
const app = 'your_app_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const records = [ record // another record ]; kintoneRecord.addAllRecords({app, records}).then((rsp) => { console.log(rsp); }).catch((err) => { // Ex: User update 6000 records: // Case 1: the error occur in record 0 // err response // { // results: [KintoneAPIException, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},{}] // } // Case 2: the error occur in record 4000 // err response // { // results: [ // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // AddRecordsResponse, // KintoneAPIException, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {} // ] // } console.log(err) });
updateRecordByID(params)
Updates details of 1 record in an app by specifying its record number.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update record by id |
params.app | Integer | yes | The kintone app ID |
params.id | Integer | yes | The record ID on kintone app |
params.record | JSONObject | yes | The record data to be update in kintone app. About the format, please look the sample below or reference at the end of this page. |
params.revision | Integer | (optional) | The revision number of record |
Return
Promise
Sample code
Update record by ID
const app = 'your_app_id'; const id = 'your_record_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const revision = 'revision_of_record'; kintoneRecord.updateRecordByID({app, id, record, revision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
updateRecordByUpdateKey(params)
Updates details of 1 record in an app by unique key.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update record by update key |
params.app | Integer | yes | The kintone app ID |
params.updateKey | JSONObject | yes | The unique key of the record to be updated. About the format, please look the sample below or reference at the end of this page. |
params.record | JSONObject | yes | The record data will be added to kintone app. About the format, please look the sample below or reference at the end of this page. |
params.revision | Integer | (optional) | The revision number of record |
Return
Promise
Sample code
Update record by UpdateKey
const app = 'your_app_id'; const updateKey = { field: 'your_fieldcode', value: 'your_fieldcode_value' }; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const revision = 'revision_of_record'; kintoneRecord.updateRecordByUpdateKey({app, updateKey, record, revision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
updateRecords(params)
Updates details of multiple records in an app, by specifying their record number, or a different unique key.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update records |
params.app | Integer | yes | The kintone app ID |
params.records | Array<JSONObject> | yes | The record data will be added to kintone app. About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Update multi records
const app = 'your_app_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const recordUpdate = { id: 'your_record_id', // Optional. Required, if updateKey will not be specified. updateKey: { // Optional. Required, if id will not be specified. field: 'your_field_code', value: 'your_field_code_value' }, record: record, revision: 'record_revision_number' // Optional }; const records = [ recordUpdate, // Another recordUpdate ] kintoneRecord.updateRecords({app, records}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
updateAllRecords(params)
- Updates details of multiple records in an app, by specifying their record number, or a different unique key.
- Can update over 2000 records to kintone app, but can't do rollback.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update all records |
params.app | Integer | yes | The kintone app ID |
params.records | Array<JSONObject> | yes | The record data will be added to kintone app. About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Update all records without limitation
const app = 'your_app_id'; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const recordUpdate = { id: 'your_record_id', // Optional. Required, if updateKey will not be specified. updateKey: { // Optional. Required, if id will not be specified. field: 'your_field_code', value: 'your_field_code_value' }, record: record, revision: 'record_revision_number' // Optional }; const records = [ recordUpdate, // Another recordUpdate ] kintoneRecord.updateAllRecords({app, records}).then((rsp) => { console.log(rsp); }).catch((err) => { // Ex: User update 6000 records: // Case 1: the error occur in record 0 // err response // { // results: [KintoneAPIException, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},{}] // } // Case 2: the error occur in record 4000 // err response // { // results: [ // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // UpdateRecordsResponse, // KintoneAPIException, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {} // ] // } console.log(err) });
deleteRecords(params)
Deletes multiple records in an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to delete records |
params.app | Integer | yes | The kintone app ID |
params.ids | Array<Integer> | yes | The list ids of record will be delete. |
Return
Promise
Sample code
Delete multi record
const app = 'your_app_id'; const ids = ['your_record_id']; kintoneRecord.deleteRecords({app, ids}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
deleteRecordsWithRevision(params)
Deletes multiple records in an app with revision.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to delete record with revision |
params.app | Integer | yes | The kintone app ID |
params.idsWithRevision | JSONObject | yes | JSONObject format by HashTable<Integer , Integer > (key: The Id of record , value: The Revision of record. ) |
Return
Promise
Sample code
Delete record with revision
const app = 'your_app_id'; const idsWithRevision = { /*your_record_id: revision_of_record*/ } kintoneRecord.deleteRecordsWithRevision({app, idsWithRevision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
deleteAllRecordsByQuery(params)
- Deletes all records in an app by query string
- Can delete over 2000 records, but can't do rollback.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Delete all records by query |
params.app | Integer | yes | The kintone app ID |
params.query | String | (optional) | The query string that will specify what records will be responded. |
Return
Promise
Sample code
Delete all records by query string
const app = 'your_app_id'; const query = 'your_query_string'; kintoneRecord.deleteAllRecordsByQuery({app, query}).then((rsp) => { console.log(rsp); }) .catch((err) => { /// Ex: User update 6000 records: // Case 1: the error occur in record 0 // err response // { // results: [KintoneAPIException, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},{}] // } // Case 2: the error occur in record 4000 // err response // { // results: [ // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // RecordsResponseDelete, // KintoneAPIException, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {}, // {} // ] // } console.log(err) });
upsertRecord(params)
Insert or update a record to kintone app. Insert the record if the updateKey doesn't exists and update the record if the updateKey exists.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to upsert record |
params.app | Integer | yes | The kintone app ID |
params.updateKey | JSONObject | yes | The unique key of the record to be updated. About the format, please look the sample below or reference at the end of this page. |
params.record | JSONObject | yes | The record data will be added to kintone app. About the format, please look the sample below or reference at the end of this page. |
params.revision | Integer | (optional) | The revision number of record |
Return
Promise
Sample code
Upsert record by UpdateKey
const app = 'your_app_id'; const updateKey = { field: 'your_fieldcode', value: 'your_fieldcode_value' }; const record = { YourFieldCode: { value: 'Value Of YourFieldCode' }, // Another fieldcode here }; const revision = 'revision_of_record'; kintoneRecord.upsertRecord({app, updateKey, record, revision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
upsertRecords(params)
Insert or update up to 1500 records to kintone app. If the records are over 1500, It is thrown Error. Insert the records if the updateKey doesn't exists and update the records if the updateKey exists.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to upsert records |
params.app | Integer | yes | The kintone app ID |
params.records | Array |
yes | The record data Array which has updateKey and record. About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Upsert records by UpdateKey
const app = 'your_app_id'; const records = [ { updateKey: { field: 'your_fieldcode', value: 'your_fieldcode_value_1' }, record: { YourFieldCode: { value: 'Value Of YourFieldCode 1' }, } }, { updateKey: { field: 'your_fieldcode', value: 'your_fieldcode_value_2' }, record: { YourFieldCode: { value: 'Value Of YourFieldCode 2' }, } }, { updateKey: { field: 'your_fieldcode', value: 'your_fieldcode_value_3' }, record: { YourFieldCode: { value: 'Value Of YourFieldCode 3' }, } } ]; recordModule.upsertRecords({app, records}).then((resp) => { console.log(resp); }).catch((e) => { /// Ex: User upsert over 100 records: // Case 1: the error occurs on a first record // err response // { // results: [KintoneAPIException, {},...] // } // Case 2: the error occurs on the 100th or more record // err response // { // results: [{},..., KintoneAPIException, {},...] // } console.log(err.get()); });
updateRecordAssignees(params)
Update assignees of a record.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update record assignees |
params.app | Integer | yes | The kintone app ID |
params.id | Integer | yes | The record ID of kintone app |
params.assignees | Array<String> | yes | The user code(s) of the assignee(s) |
params.revision | Integer | (option) | The revision number of record |
Return
Promise
Sample code
update record Assignees
const app = 'your_app_id'; const id = 'your_record_id'; const assignees = ['your_assignee(s)']; const revision = 'revision_of_record'; kintoneRecord.updateRecordAssignees({app, id, assignees, revision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
updateRecordStatus(params)
Updates the Status of a record of an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update record status |
params.app | Integer | yes | The kintone app ID. |
params.id | Integer | yes | The record ID on kintone app. |
params.action | String | yes | The Action name will be run. |
params.assignee | String | (Conditionally required) | The next Assignee. Specify the Assignee's log in name.Required, if the "Assignee List" of the current status is set to "User chooses one assignee from the list to take action", and a selectable assignee exists. |
params.revision | Integer | (optional) | The revision of record |
Return
Promise
Sample code
Update record status
const app = 'your_app_id'; const id = 'your_record_id'; const action = 'your_action_name'; const assignee = 'your_assignee'; const revision = 'revision_of_record'; kintoneRecord.updateRecordStatus({app, id, action, assignee, revision}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
updateRecordsStatus(params)
Updates the Status of multiple records of an app.
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to update records status |
params.app | Integer | yes | The kintone app ID |
params.records | Array<JSONObject> | yes | The recod status data. See belowsample codee or reference at the end of this page to know format. |
Return
Promise
Sample code
Update multi record status
const app = 'your_app_id'; const recordStatusUpdateItem = { id: 'your_record_id', action: 'your_action_name', assignee: 'your_assignee', revision: 'your_record_revision' } const records = [ recordStatusUpdateItem, // another data like recordStatusUpdateItem ]; kintoneRecord.updateRecordsStatus({app, records}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
getComments(params)
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to get comments |
params.app | Integer | yes | The kintone app ID |
params.record | Integer | yes | The ID of record |
params.order | String | (optional) | The sort order of the Comment ID. Please select asc or desc |
params.offset | Integer | (optional) | The number of first comments will be ignored. |
params.limit | Integer | (optional) | The number of records to retrieve. |
Return
Promise
Sample code
Get comments
const app = 'your_app_id'; const record = 'your_record_id'; const order = 'your_order_type'; // asc or desc const offset = 'your_offset_number'; const limit = 'your_limit number'; kintoneRecord.getComments({app, record, order, offset, limit}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
addComment(params)
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to add comment |
params.app | Integer | yes | The kintone app ID |
params.record | Integer | yes | The ID of record |
params.comment | JSONObject | yes | About the format, please look the sample below or reference at the end of this page. |
Return
Promise
Sample code
Add comment
const app = 'your_app_id'; const record = 'your_record_id'; const comment = { text: 'your_comment_content', mentions: [ { code: 'your_member_code', type: 'your_member_type' // either `USER` or `GROUP` or `ORGANIZATION` }, // another mention here ] }; kintoneRecord.addComment({app, record, comment}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
deleteComment(params)
Parameter
Name | Type | Required | Description |
---|---|---|---|
params | Object | yes | Params to delete comment |
params.app | Integer | yes | The kintone app ID |
params.record | Integer | yes | The record ID on kintone app |
params.comment | Integer | yes | The comment ID on kintone record |
Return
Promise
Sample code
Delete comment
const app = 'your_app_id'; const record = 'your_record_id'; const comment = 'your_comment_id'; kintoneRecord.deleteComment({app, record, comment}).then((rsp) => { console.log(rsp); }).catch((err) => { // This SDK return err with KintoneAPIException console.log(err.get()); });
Reference
- Get Record
on developer network
- Add Record
on developer network
- Update Record
on developer network
- Delete Record
on developer network
- Get Comments
on developer network
- Add Comment
on developer network
- Delete Comment
on developer network
- Update Record Status
on developer network
- Update Record Assignees
on developer network