Here is a guide on how to modify this codebase to use your own field codes.
Here are all the lines of code you need to change in order for this Kintone x React App setup to work when you change the field codes:
Here are the initial fields & their configurations for the Kintone Web Database App:
Field Type | Field Name | Field Code |
---|---|---|
Text | Title | title |
Text | Author | author |
You can always change the field name without any issues. No need to update the code.
For the Backend, you need to update backend/server.js's requestBody
object.
const requestBody = {
'app': appID,
'record': {
'title': {
'value': req.body.title
},
'author': {
'value': req.body.author
}
}
};
For the Frontend, you need to update the following:
- frontend/src/requests/getRecords.js's
ListItemArray
object - frontend/src/requests/postRecords.js's
recordBodyParameters
object
const ListItemArray = jsonResponse.records.map(
record => {
uniqueKey = record.Record_number.value;
title = record.title.value;
author = record.author.value;
return <li key={uniqueKey}><b>{title}</b> written by {author}</li>
}
);
const recordBodyParameters = {
'title': title,
author // ES6 syntax that functions the same as above
}
Here is an example of how the codebase would look like if you changed the field codes from title
and author
to city
and country
.
title
would be changed tocity
author
would be changed tocountry
Here would be the updated fields & their configurations for the Kintone Web Database App:
Field Type | Field Name | Field Code |
---|---|---|
Text | City | city |
Text | Country | country |
You can always change the field name without any issues. No need to update the code.
Review the Get Record > Sample Response API Doc to see the expected output of the Get Record API for the desired field type.
Update backend/server.js's requestBody
object like so:
const requestBody = {
'app': appID,
'record': {
'city': {
'value': req.body.city
},
'country': {
'value': req.body.country
}
}
};
Update the frontend/src/requests/getRecords.js's ListItemArray
object like so:
const ListItemArray = jsonResponse.records.map(
record => {
uniqueKey = record.Record_number.value;
city = record.city.value;
country = record.country.value;
return <li key={uniqueKey}>Option {uniqueKey} : {city}, {country}</li>
}
);
-
frontend/src/requests/postRecords.js's
recordBodyParameters
objectconst recordBodyParameters = { city, country }