Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

20160218 Developer Summit 2016

2,808 views

Published on

2016/2/18 デブサミ2016のkintoneハンズオンの資料です

Published in: Software

20160218 Developer Summit 2016

  1. 1. aFunctionA(param, function(resultParam){ somethingToDo(); });
  2. 2. aFunctionA(paramA, function(resultA){ aFunctionB(paramB, function(resultB){ aFunctionC(paramC, function(resultC){ somethingToDo(); }); }); });
  3. 3. aFunctionA(paramA) .then(aFunctionB) .then(aFunctionC) .then(somethingToDo);
  4. 4. function promiseFuncA(param){ return new kintone.Promise(resolve, reject){ ayncFunction(param, function(err, data){ if(err){ reject(err); }else{ resolve(data); } } } }
  5. 5. promiseFuncA().then(function(data){ doSomething(); });
  6. 6. kintone.api(“/k/v1/record”, “GET”, param) kintone.api(“/k/v1/record”, “GET”, param) .then(function(response){ });
  7. 7. jQuery.noConflict(); (function($) { "use strict"; var events = [“app.record.edit.submit”]; kintone.events.on(events, function(e) { var record = e.record; var billNo = record["billNo"]["value"]; var queryParam = { “app”: 44, "query": "billNo = ¥"" + billNo + "¥"” }; return kintone.api("/k/v1/records", "GET",queryParam) }); }); })(jQuery);
  8. 8. for(var i = 0; i < length; i++){ kintone.api(.......).then(.....); }
  9. 9. return kintone.api("/k/v1/records", "GET",queryParam) .then(function(reponse){ var details = response["records"]; var total = 0; $.each(details, function(index, item){ total += parseInt(item["price"]["value"]); }); record["totalPrice"]["value"] = total; return e; }).then(function(){ }); });
  10. 10. (function() { "use strict"; function fetchRecords(appId, opt_offset, opt_limit, opt_records) { var offset = opt_offset || 0; var limit = opt_limit || 100; var allRecords = opt_records || []; var params = {app: appId, query: 'order by レコード番号 asc limit ' + limit + ' offset ' + offset}; return kintone.api('/k/v1/records', 'GET', params).then(function(resp) { allRecords = allRecords.concat(resp.records); if (resp.records.length === limit) { return fetchRecords(appId, offset + limit, limit, allRecords); } return allRecords; }); } fetchRecords(kintone.app.getId()).then(function(records) { console.log(records); }); })();
  11. 11. var countParam = { "app" : APP_ID, "query" : "limit 1", "totalCount": true }; return kintone.api("/k/v1/records", "GET", countParam).then(function (resp) { var totalCount = parseInt(resp.totalCount); var loopCount = Math.ceil(totalCount / 500); var loopArray = new Array(loopCount); return kintone.Promise.all($.map(loopArray, function (aItem, index) { var offset = index * KINTONE_RECORD_MAX; var param = { "app" : APP_ID, "query" : "limit 500 offset " + offset, "totalCount": true }; var total = 0; return kintone.api("/k/v1/records", "GET", param).then(function (resp) { var records = resp.records; total = parseInt(resp.totalCount); records.map(function (record, i){ doSomthing();}); }); })); });
  12. 12. http://kintonecafe.com/

×