Episode 483: Synchronizing Daily with Master Data in kintone

Monday, May 16, 2016
"Customer list" is typical of "database". (Weather managed in paper or in computer.)

Data stored in "Database" is roughly classified into
  • A) Master information (Master type data)
    • Product master
    • Client master
    • Price list, etc.
  • B) Log information (Transaction type data)
    • Payment history
    • Orders record
    • Access log, etc.
And in day-to-day business, there are many occasions that you want to refer to data which is classified in A), master type data.


The following Business Process is a mechanism to synchronize "Client Master data" in the Workflow environment with client master information which is managed in "kintone", a Cloud Database, on a daily basis. (It may be considered as a Batch processing.) It is excellent for not only all the Steps having been automated, but also being capable of manually synchronization at any time.

After all, it becomes possible to refer the latest "Client Master" in a variety of business, such as "Estimate Process", "Order report Process", or "Billing Process". You might be able to eliminate so-called "name identification". (Moreover, it also has the meaning of auto-backup of data in kintone.)

[Client Master Synchronization]


"kintone", a Cloud-database service, provides APIs.

It will be capable of synchronization of various data by Server-to-server communication in the following format.
  • https://${YOUR-DOMAIN}.cybozu.com/k/v1/record.json?app=1&id=1
  • https://${YOUR-DOMAIN}.cybozu.com/k/v1/records.json?app=1
Note) For utilizing kintone APIs, "Custom header feature" (Questetra BPM Suite v11.0: 2016-05-23) is required.

[API communication]
For anyone who is capable of "Excel function", for example, half a day will be enough for learning to "mechanism of API communication" from "How to setup Master information table". (However, there may be somebody who feel that it is tricky on the point that it is sent and received in a text format of JSON.)

* By the way, I guess there are many people who wonder "Where is App ID indicated at?" You just refer to the number in the URL for browsing the list ( https://example.cybozu.com/k/3/). "3" is the number in this example.


= Overview of the Master information table creation (kintone)
  1. Name the information table (Customers)
  2. Write the description of the information table
  3. Define data items
  4. (Drag & Drop a format of the item that is required for Master management)
  5. (Setup [Field code] which is required for auto-processing respectively)
  6. (Confirm the alignment of items)
  7. Setup the view of All items list
  8. Setup the communication for data synchronization (API Token)
  9. (Write down the API token)
  10. Run the Master information table
  11. Register client data into the Master
  12. (Refer to the client data list)

[Capture: 1-12]
(1)


= Overview of Auto-request configuration
  1. Place a Throwing Message Intermediate Event icon
  2. Fill in the [Access URL] to kintone API (Method:GET)
  3. Fill in "X-Cybozu-API-Token" and "API Token" into custom header setting
  4. Specify the data item to store Response JSON

= Setting sample of Script Step "List Generate" (Server-side JavaScript)
//// == Retrieving == 
var myJson = data.get("1") + ""; // JSON text 

//// == Calculating == 
var customersData = JSON.parse( myJson ); 
var numOfRecords = customersData.totalCount - 0; 

var value_id_list = ""; 
var display_label_list = ""; 
for (i = 0; i < numOfRecords; i++){ 
  value_id_list += customersData.records[i].customerCode.value + "\n"; 
  display_label_list += customersData.records[i].customerName.value + "\n"; 
} 

//// == Updating == 
retVal.put("4", value_id_list); 
retVal.put("5", display_label_list); 


= JSON sample (Line breaks and indent have been added for easy-to understand)
// Value of All record all field of which viewing is authorized will be returned if query or fields is omitted 

{"records":[
  {"customerName":{"type":"SINGLE_LINE_TEXT","value":"国立大学法人京都大学"},
   "Updated_datetime":{"type":"UPDATED_TIME","value":"2016-05-11T01:15:00Z"},
   "Created_datetime":{"type":"CREATED_TIME","value":"2016-05-11T01:15:00Z"},
   "Created_by":{"type":"CREATOR","value":{"code":"example@gmail.com","name":"example@gmail.com"}},
   "Record_number":{"type":"RECORD_NUMBER","value":"3"},
   "$revision":{"type":"__REVISION__","value":"1"},
   "tel":{"type":"LINK","value":"075-753-7531"},
   "personInCharge":{"type":"SINGLE_LINE_TEXT","value":""},
   "url":{"type":"LINK","value":"http://www.kyoto-u.ac.jp/"},
   "email":{"type":"LINK","value":""},
   "decileRank":{"type":"DROP_DOWN","value":"E"},
   "customerCode":{"type":"SINGLE_LINE_TEXT","value":"3130005005532#www.kyoto-u.ac.jp"},
   "$id":{"type":"__ID__","value":"3"},
   "note":{"type":"MULTI_LINE_TEXT","value":""},
   "Updated_by":{"type":"MODIFIER","value":{"code":"example@gmail.com","name":"example@gmail.com"}}
  },
  {"customerName":{"type":"SINGLE_LINE_TEXT","value":"Google Inc."},
   "Updated_datetime":{"type":"UPDATED_TIME","value":"2016-05-11T01:16:00Z"},
   "Created_datetime":{"type":"CREATED_TIME","value":"2016-05-11T01:13:00Z"},
   "Created_by":{"type":"CREATOR","value":{"code":"example@gmail.com","name":"example@gmail.com"}},
   "Record_number":{"type":"RECORD_NUMBER","value":"2"},
   "$revision":{"type":"__REVISION__","value":"2"},"tel":{"type":"LINK","value":""},
   "personInCharge":{"type":"SINGLE_LINE_TEXT","value":"Sergey Brin"},
   "url":{"type":"LINK","value":"https://www.google.com/"},
   "email":{"type":"LINK","value":""},
   "decileRank":{"type":"DROP_DOWN","value":"J"},
   "customerCode":{"type":"SINGLE_LINE_TEXT","value":"9999999999999#www.google.com"},
   "$id":{"type":"__ID__","value":"2"},
   "note":{"type":"MULTI_LINE_TEXT","value":""},
   "Updated_by":{"type":"MODIFIER","value":{"code":"example@gmail.com","name":"example@gmail.com"}}
  },
  {"customerName":{"type":"SINGLE_LINE_TEXT",
   "value":"Questetra, Inc."},
   "Updated_datetime":{"type":"UPDATED_TIME","value":"2016-05-11T01:11:00Z"},
   "Created_datetime":{"type":"CREATED_TIME","value":"2016-05-11T01:11:00Z"},
   "Created_by":{"type":"CREATOR","value":{"code":"example@gmail.com","name":"example@gmail.com"}},
   "Record_number":{"type":"RECORD_NUMBER","value":"1"},
   "$revision":{"type":"__REVISION__","value":"1"},
   "tel":{"type":"LINK","value":"075-205-5007"},
   "personInCharge":{"type":"SINGLE_LINE_TEXT","value":"IMAMURA Genichi"},
   "url":{"type":"LINK","value":"https://www.questetra.com/"},
   "email":{"type":"LINK","value":"support@questetra.com"},
   "decileRank":{"type":"DROP_DOWN","value":"A"},
   "customerCode":{"type":"SINGLE_LINE_TEXT","value":"6130001031686#www.questetra.com"},
   "$id":{"type":"__ID__","value":"1"},
   "note":{"type":"MULTI_LINE_TEXT","value":"Kyoto"},
   "Updated_by":{"type":"MODIFIER","value":{"code":"example@gmail.com","name":"example@gmail.com"}}
  }],
 "totalCount":"3"}


[Client Master Synchronization:"1. Confirmation" screen]

[Data Items list]


[Free Download]
<Similar Models>
<<Related Articles>>

[Japanese Entry (和文記事)]