BulkRequest
The Bulk Request API allows multiple API requests to run on multiple kintone apps. The below API can be used with the Bulk Request API:
- Add Record
- Add Records
- Update Record
- Update Records
- Delete Records
- Update Status
- Update Statuses
- Update Assignees
Constructor
Parameter
Name | Type | Required | Description |
---|---|---|---|
connection | Connection | yes | The connection module of this SDK. |
Sample code
Init bulk request module
Source codelet username = "your_username" let password = "your_password" let domain = "your_domain" // Init authenticationAuth let auth = Auth() auth.setPasswordAuth(username, password) // Init Connection without "guest space ID" let connection = Connection(domain, auth) // Init Bulk request var bulkRequest = BulkRequest(connection);
Methods
All below methods (excluded execute()
method) will add the request to the queue, you must execute the execute()
function to get the result of BulkRequest.
addRecord(_ app: Int?, _ record: [String:FieldValue]?)
Parameter
See at Record - addRecord
Return
Sample code
add Record
Source codevar record: [String: FieldValue] = [:] let fv = FieldValue() fv.setType(FieldType.SINGLE_LINE_TEXT) fv.setValue("test_AddRecord") record["Your_Field_Code"] = fv bulkRequest = try! bulkRequest?.addRecord(1, record)
addRecords(_ app: Int?, _ records: [[String:FieldValue]])
Parameter
See at Record - addRecords
Return
Sample code
add multiple Records
Source code// create add data var addData1: Dictionary= [:] var addData2: Dictionary = [:] var field1 = FieldValue() var field2 = FieldValue() field1.setType(FieldType.SINGLE_LINE_TEXT) field1.setValue("Test Value1") field2.setType(FieldType.SINGLE_LINE_TEXT) field2.setValue("Test Value2") addData1[{your_field_code}] = field1 addData2[{your_field_code}] = field2 var = [addData1, addData2] // create addRecords bulk request let appID = 311 bulkRequest = try! bulkRequest?.addRecords(appID, addDataList);
updateRecordByID(_ app: Int, _ id: Int, _ record: [String:FieldValue]?, _ revision: Int?)
Parameter
See at Record - updateRecordByID
Return
Sample code
update Record By ID
Source code// create add data var updateData:Dictionary= [:] var field = FieldValue() field.setType(FieldType.SINGLE_LINE_TEXT) field.setValue("Test Value Update") updateData[{your_field_code}] = field // create updateRecordByID bulk request let appID = {your_app_id} let updRecID = {your_record_id} bulkRequest = try! bulkRequest?.updateRecordByID(appID, updRecID, updateData, nil);
updateRecordByUpdateKey(_ app: Int, _ updateKey: RecordUpdateKey, _ record: [String:FieldValue]?, _ revision: Int?)
Parameter
See at Record - updateRecordByUpdateKey
Return
Sample code
update Record By UpdateKey
Source code// create update data var updateData: Dictionary= [:] var field = FieldValue() field.setType(FieldType.SINGLE_LINE_TEXT) field.setValue("Test Value Update For Key") updateData[{your_field_code}] = field // create update key let updKey = RecordUpdateKey("{your_field_code}", "update key value") let appID = {your_app_id} // create updateRecordByUpdateKey bulk request bulkRequest = try! bulkRequest?.updateRecordByUpdateKey(appID, updKey, updateData, nil);
updateRecords(_ app: Int?, _ records: [RecordUpdateItem])
Parameter
See at Record - updateRecords
Return
Sample code
update multiple Records
Source code// create update data var recId1 = {your_record_id} var recId2 = {your_record_id} var updateData1: Dictionary= [:] var updateData2: Dictionary = [:] var field1 = FieldValue() var field2 = FieldValue() field1.setType(FieldType.SINGLE_LINE_TEXT) field1.setValue("Test Update Value1 ") field2.setType(FieldType.SINGLE_LINE_TEXT) field2.setValue("Test Update Value2") updateData1[{your_field_code}] = field1 updateData2[{your_field_code}] = field2 var updateDataItem1 = RecordUpdateItem(recId1, nil, nil, updateData1) var updateDataItem2 = RecordUpdateItem(recId2, nil, nil, updateData2) let updateItemList = [updateDataItem1 , updateDataItem2] // create updateRecords bulk request let appID = {your_app_id} bulkRequest = try! bulkRequest?.updateRecords(appID, updateItemList);
deleteRecords(_ app: Int?, _ ids: [Int])
Parameter
See at Record - deleteRecords
Return
Sample code
Bulk Delete Records
Source code// create deleteRecords bulk request let appID = {your_app_id} let delRecordID1 = {your_record_id1} let delRecordID2 = {your_record_id2} let delIdList = [delRecordID1, delRecordID2] bulkRequest = try! bulkRequest?.deleteRecords(appID, delIdList);
deleteRecordsWithRevision(_ app: Int?, _ idWithRevision: [Int:Int>])
Parameter
See at Record - deleteRecordsWithRevision
Return
Sample code
delete Records With Revision
Source code// create deleteRecordsWithRevision bulk request let appID = {your_app_id} var delIdAndRevision: Dictionary= [:] delIdAndRevision[{your_record_id}] = {your_revision_id} delIdAndRevision[{your_record_id}] = {your_revision_id} bulkRequest = try! bulkRequest?.deleteRecordsWithRevision(appID, delIdAndRevision);
updateRecordAssignees(_ app: Int, _ id: Int, _ assignees: [String], _ revision: Int?)
Parameter
See at Record - updateRecordAssignees
Return
Sample code
Update the Assignees for the record
Source code// create updateRecordAssignees bulk request let appID = {your_app_od} let updRecID = {your_record_id} let assignees = ["{your_user_code}"] bulkRequest = try! bulkRequest?.updateRecordAssignees(appID, updRecID, assignees, nil);
updateRecordStatus(_ app: Int, _ id: Int, _ action: String, _ assignee: String?, _ revision: Int?)
Parameter
See at Record - updateRecordStatus
Return
Sample code
Update the status of a single record
Source code// create updateRecordStatus bulk request let appID = {your_app_id} let updRecID = {your_record_id} let assignees = "{your_user_code}" let status = "{your_status}" bulkRequest = try! bulkRequest?.updateRecordStatus(appID, updRecID, status, assignees, nil);
updateRecordsStatus(_ app: Int, _ records: [RecordUpdateStatusItem])
Parameter
See at Record - updateRecordsStatus
Return
Sample code
Update the status of multiple records in bulk
Source code// create updateRecordsStatus bulk request let appID = {your_app_id} let updRecID1 = {your_record_id1} let updRecID2 = {your_record_id2} let assignees1 = [{your_login_code1}] let assignees2 = [{your_login_code2}] let status1 = {your_update_status1} let status2 = {your_update_status2} let item1 = RecordUpdateStatusItem(status1, assignees1, updRecID1, nil) let item2 = RecordUpdateStatusItem(status2, assignees2, updRecID2, nil) let itemList = [item1, item2] bulkRequest = try! bulkRequest?.updateRecordsStatus(appID, itemList);
execute()
Execute the bulk request and get data response
Parameter
(none)
Return
Promise<BulkRequestResponse>
Sample code
Execute bulk request
Source codebulkRequest?.execute().then{responses in print(responses) }.catch{error in if error is KintoneAPIException { print((error as! KintoneAPIException).toString()!) } else { print((error as! Error).localizedDescription)) } }