Snippets とは
Run snippets of JavaScript
Snippets
アプリのフィールド、レイアウト取得
{
const app = kintone.app.getId();
const url = "/k/v1/app/form/fields.json";
const { properties: fields } = await kintone.api(url, "GET", { app });
console.groupCollapsed("fields");
for (const field of Object.values(fields)) {
console.log(field);
}
console.groupEnd();
}
{
const app = kintone.app.getId();
const url = "/k/v1/app/form/layout.json";
const { layout: layouts } = await kintone.api(url, "GET", { app });
console.groupCollapsed("layouts");
for (const layout of Object.values(layouts)) {
console.log(layout);
}
console.groupEnd();
}
レコード取得
{
const app = kintone.app.getId();
const url = "/k/v1/record.json";
const body = {
id: kintone.app.record.getId(),
app,
};
const { record } = await kintone.api(url, "GET", body);
console.group("record");
for (const [key, value] of Object.entries(record)) {
console.log(key, value);
}
console.groupEnd();
}
レコード登録
{
const app = kintone.app.getId();
const url = "/k/v1/record.json";
const body = {
app,
record: {},
};
const res = await kintone.api(url, "POST", body);
console.log(res);
}