# googleフォームとの連携について

**URL:** <https://community.cybozu.dev/t/topic/4032>\
**Category:** kintone 開発相談\
**Created:** [2019 年 5 月 20 日午前 8:57 UTC](https://community.cybozu.dev/t/topic/4032 "2019-05-20T08:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account1095](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Legacy\_Account1095](https://community.cybozu.dev/u/Legacy_Account1095)\
**Post date:** [2019 年 5 月 20 日午前 8:57 UTC](https://community.cybozu.dev/t/topic/4032/1 "2019-05-20T08:57:02Z")

</div>

お世話になっております。キントーンではじめてjavascriptに触り勉強中です。

&nbsp;

タイトルの通り、googleフォームとの連携についてうまくキントーンに登録されず悩んでおります。

初心者ながらに

[Google フォームとkintoneを連携してみよう！](https://community.cybozu.dev/hc/ja/articles/115003856483-Google-%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%A8kintone%E3%82%92%E9%80%A3%E6%90%BA%E3%81%97%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86-)

[googleフォームとの連携について](https://community.cybozu.dev/hc/ja/community/posts/360014862703-google%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%A8%E3%81%AE%E9%80%A3%E6%90%BA%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6?input_string=google%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%A8%E3%81%AE%E9%80%A3%E6%90%BA%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6)

など過去記事を参照して作成したものの、googleのエラーでは

SyntaxError: Unexpected comma in array literal at sendToKintone(キントーン連携:66)

「構文エラー」となっており、確認を何度もしていますが、どこが悪いのかが見当がつきません。

キントーン連携：66の列は

var response = manager.create(“YOUR\_APPLICATION1”, records);//kintone レコードの生成

が相当しています。

&nbsp;

また、F12のコンソールでは「送信先がみつからない」というエラーです。

ただ、IDやAPIトークンなどはあっていると思います。

説明ページ通りにそれぞれの設定もしました。

&nbsp;

こちらのコードでもし問題点にお気づきの方いらっしゃいましたら

ご教授いただけますと幸いです。

長いコードになりますが、よろしくお願いいたします。

&nbsp;

function getFormResponse(e) {  
‘use strict’;  
var itemResponses = e.response.getItemResponses();//フォームの入力内容を取得  
var records = ‘[’;  
for (var i = 0; i \< itemResponses.length; i++) {  
var itemResponse = itemResponses[i];  
switch (itemResponse.getItem().getTitle()) {  
case “法人名”:  
records += Utilities.formatString(‘,“法人名” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “店舗名”:  
records += Utilities.formatString(‘,“店舗名” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “商品名”:  
records += Utilities.formatString(‘,“商品名” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “金額”:  
records += Utilities.formatString(‘,“金額” : { “value”: “%s” }’,  
itemResponse.getResponse());//回答者のEmailアドレスの取得  
break;  
case “契約開始”:  
records += Utilities.formatString(‘,“契約開始” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “請求開始”:  
records += Utilities.formatString(‘,“請求開始” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “希望納期（日付）”:  
records += Utilities.formatString(‘,“希望納期\_日付” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “希望納期（時刻）”:  
records += Utilities.formatString(‘,“希望納期\_時刻” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “営業担当者”:  
records += Utilities.formatString(‘,“営業担当者” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
case “備考”:  
records += Utilities.formatString(‘,“備考” : { “value”: “%s” }’,  
itemResponse.getResponse());//質問に対する回答を取得  
break;  
}  
}  
records += ‘}]’;  
Logger.log(‘Response JSON is “%s”’, records);  
return records;  
}

function sendToKintone(e) {  
‘use strict’;  
Logger.log(‘Form submitted’);  
var subdomain = “◆◆◆([https://◆◆◆.cybozu.com/の部分](https://xn--w1haa.cybozu.com/%E3%81%AE%E9%83%A8%E5%88%86))”;//サブドメイン名  
var apps = {  
YOUR\_APPLICATION1: { appid: 22, name: “見積書作成依頼”, token: “該当アプリのAPIトークン” }  
};  
var manager = new KintoneManager.KintoneManager(subdomain, apps);// ライブラリーの初期化  
var str = getFormResponse(e);  
str = str.replace(//g, "").replace(/\r/g, “\r”).replace(/\t/g, “\t”);  
var records = JSON.parse(str);//JSON形式に変換  
var response = manager.create(“YOUR\_APPLICATION1”, records);//kintone レコードの生成  
// ステータスコード  
// 成功すれば200になる  
var code = response.getResponseCode();  
Logger.log(‘Response code is “%s”’, code);  
}

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1051](https://avatars.discourse-cdn.com/v4/letter/l/9de053/32.png) [@Legacy\_Account1051](https://community.cybozu.dev/u/Legacy_Account1051)\
**Post date:** [2019 年 5 月 21 日午前 4:14 UTC](https://community.cybozu.dev/t/topic/4032/2 "2019-05-21T04:14:05Z")

</div>

こんにちは。

JSONの構文エラーですね。

```
case "法人名":
records += Utilities.formatString(',"法人名" : { "value": "%s" }',

```

パッと見て”法人名”の先頭にカンマがついてるのがエラー原因かなと思いました。

フォームの一番上、レコードに登録する最初のデータが法人名なら

```
case "法人名":
records += Utilities.formatString('{"法人名" : { "value": "%s" }',

```

これに書き換えて試してみてください。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1095](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Legacy\_Account1095](https://community.cybozu.dev/u/Legacy_Account1095)\
**Post date:** [2019 年 5 月 21 日午前 8:19 UTC](https://community.cybozu.dev/t/topic/4032/3 "2019-05-21T08:19:01Z")

</div>

TK様

&nbsp;

こんにちは、お世話になっております。

試したところ、はじめて送信と登録ができました！！！！「完了」の文字に感動です！！

何日もエラーばかりで、心が折れかけておりました。

本当に、本当にありがとうございます！！

&nbsp;

最初飛ばなかった日付と時刻も、タイミングが悪かったようで更新したあと反映したらきちんとはいりました！！

ありがとうございました！！

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1051](https://avatars.discourse-cdn.com/v4/letter/l/9de053/32.png) [@Legacy\_Account1051](https://community.cybozu.dev/u/Legacy_Account1051)\
**Post date:** [2019 年 5 月 21 日午前 8:27 UTC](https://community.cybozu.dev/t/topic/4032/4 "2019-05-21T08:27:50Z")

</div>

解決して何よりです。

&nbsp;

軽く調べたところそれで合ってるっぽいですねー。

試してみてください！

[https://sites.google.com/site/gasgaidobukku/utilities/formatdate](https://sites.google.com/site/gasgaidobukku/utilities/formatdate)

&nbsp;

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1095](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@Legacy\_Account1095](https://community.cybozu.dev/u/Legacy_Account1095)\
**Post date:** [2019 年 5 月 21 日午前 9:01 UTC](https://community.cybozu.dev/t/topic/4032/5 "2019-05-21T09:01:00Z")

</div>

TK様

リンクまでありがとうございます！！！勉強させていただきます。

&nbsp;

最初飛ばなかった日付と時刻は、キントーンのアプリ更新とのタイミングが悪かったようで

更新したあと反映したらきちんとはいりました！！

何度お礼を言ったらいいか…！

本当にありがとうございました！
