# クエリで取得したフィールド情報を使う（autocomplete）

**URL:** https://community.cybozu.dev/t/topic/5310
**Category:** kintone 開発相談
**Created:** [2021 年 9 月 28 日午前 4:31 UTC](https://community.cybozu.dev/t/topic/5310 "2021-09-28T04:31:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Legacy\_Account297](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@Legacy\_Account297](https://community.cybozu.dev/u/Legacy_Account297)
#### Post date: [2021 年 9 月 28 日午前 4:31 UTC](https://community.cybozu.dev/t/topic/5310/1 "2021-09-28T04:31:36Z")

</div>

お世話になっております。

下記の通り「検索キーワード1」のようにクエリで取得したフィールド情報を使って

利用したいと考えています。（「検索キーワード2」）

「words2」を使って行うことは可能でしょうか？

ご教授のほどよろしくお願いいたします。

&nbsp;

&nbsp;

```
// 検索キーワードその１
var search_word1 = document.createElement('input');
search_word1.id = 'keywordList';
$(function() {
var words = [
"Java",
"JavaScript",

];
$( "#keywordList" ).autocomplete({
source: words,

});

});

```

&nbsp;

```
// 検索キーワードその２
var search_word2 = document.createElement('input');
search_word2.id = 'keywordList2';
$(function() {
var body = {
'app': appId,
'fields': ['レコード番号', 'メーカー名'],
'query': 'メーカー名 != "" order by レコード番号 asc',
};

kintone.api('/k/v1/records', 'GET', body).then(function(resp) {

for (var i = 0; i < resp.records.length; i++) {
var words2 =resp['records'][i]['メーカー名']['value']
console.log(words2)
}

$( "#keywordList2" ).autocomplete({
source: words2,
})

});
});

```

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

### Author: ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)
#### Post date: [2021 年 9 月 28 日午前 7:31 UTC](https://community.cybozu.dev/t/topic/5310/2 "2021-09-28T07:31:59Z")

</div>

青山昌司さん

こんにちは。

&nbsp;

検索キーワードその1と同様に

words2の中身がクエリで取得した配列になれば、可能になると思います。

```
var words2 = [];
for (var i = 0; i < resp.records.length; i++) {
// words2配列に追加
words2.push(resp['records'][i]['メーカー名']['value']);
console.log(words2);
}

```

---

<div class="post-metadata">

### Author: ![Legacy\_Account297](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@Legacy\_Account297](https://community.cybozu.dev/u/Legacy_Account297)
#### Post date: [2021 年 9 月 28 日午前 7:58 UTC](https://community.cybozu.dev/t/topic/5310/3 "2021-09-28T07:58:25Z")

</div>

[koichi](https://community.cybozu.dev/hc/ja/profiles/900225082446-koichi)さま

お世話になっております。

無事取得できました！

また一つ勉強になりました。ご連絡ありがとうございました^^

今後ともよろしくお願いいたします。
