Episode 484: Addition of New Client via kintone API

Monday, May 23, 2016
I introduced a fully automated Workflow that is

> to update the Workflow platform common "Client Master" by receiving JSON response from kintone API,

in the last post.

In this post, I would like to introduce how to

> Update the "Client Master" in kintone by sending JSON data to kintone API.

More specifically, it is a mechanism that suppliers (customer code and customer name) is added to the "customer master" on the kintone, upon the moment when a start of trading in the "Credit Management Workflow" has been approved.

After all, it is configured that JSON string such as

{
  "app": "3",
  "record": {
    "customerCode": {
      "value": "9999999999999#www.example.com"
    },
    "customerName": {
      "value": "XYZ Inc"
    }
  }
}

POSTed to kintone API at the downstream of the Workflow.

* JSON: JavaScript Object Notation (Mass of data in which the pair of "key" and "value" have been enumerated)

[Credit Management]

[Credit Management:"1. Registration of Client" screen]

In this example, JSON string for data federation will be created automatically after completion of the third Step.

Needless to say, the information of "Client code" and "Client's name", which have been entered at the upstream Step, will be stored there. However, knowledge and experience about ECMA script (server-side JavaScript) are Inevitably required to configure "Script Step" in order to automatically generate the JSON string.

Even though about 10 lines of Script, you should use it after having ascertained firmly if you can continue to maintain as an organization.

However, I think you will need to comprehend them to survive this "Cloud-utilization era", although"API" or "JSON" may sound like "space language" now. Just like the words of " Email" or "URL" used to sound like "space language" before "Internet era" has come...

Note) For utilizing kintone APIs, "Custom header feature" (Questetra BPM Suite v11.0: 2016-05-23) is required.

= Setting sample of Script Step "JSON Generate" (Server-side JavaScript)
//// == Retrieving == 
var cCode = data.get("3") + ""; 
var cName = data.get("4") + ""; 

//// == Calculating == 
// Multidimensional object to match the kintone app to connect to 

var myObj = { 
  "app": "3", 
  "record": { 
    "customerCode": { 
    "value": "9999999999999#www.example.com" 
    }, 
    "customerName": { 
      "value": "XYZ Inc" 
    } 
  } 
}; 

myObj.record.customerCode.value = cCode; 
myObj.record.customerName.value = cName; 

var myJsonText = JSON.stringify( myObj ); 

//// == Updating == 
retVal.put("2", myJsonText ); 

[Data Items list]


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

[Japanese Entry (ε’Œζ–‡θ¨˜δΊ‹)]