Question / Problem
Generate Text to Text field via checkbox?
Current Situation
I want to add the text value when the user clicks the checkbox.
The value can be stacked and deleted when unchecking the checkbox.
Code / Attempts
Share your code and setup
(function() {
"use strict";
var events = [
'app.record.create.change.Air_Export',
'app.record.edit.change.Air_Export',
'app.record.create.change.Air_Import',
'app.record.edit.change.Air_Import',
'app.record.create.change.Sea_Export',
'app.record.edit.change.Sea_Export',
'app.record.create.change.Sea_Import',
'app.record.edit.change.Sea_Import',
'app.record.create.change.Warehouse',
'app.record.edit.change.Warehouse',
'app.record.create.change.Packing',
'app.record.edit.change.Packing',
'app.record.create.change.Removal',
'app.record.edit.change.Removal',
'app.record.create.change.Crossborder',
'app.record.edit.change.Crossborder',
'app.record.create.change.Transport',
'app.record.edit.change.Transport',
'app.record.create.change.PDF_Field',
'app.record.edit.change.PDF_Field'
];
// Add event listener to the checkbox field
kintone.events.on(events, function(event) {
var record = event.record;
var statusValue_AEX = record['Air_Export'].value;
var statusValue_AIM = record['Air_Import'].value;
var statusValue_OEX = record['Sea_Export'].value;
var statusValue_OIM = record['Sea_Import'].value;
var statusValue_WH = record['Warehouse'].value;
var statusValue_PK = record['Packing'].value;
var statusValue_RMV = record['Removal'].value;
var statusValue_CB = record['Crossborder'].value;
var statusValue_TR = record['Transport'].value;
var textareaValue = record['PDF_Field'].value;;
// If checkbox is checked, update textarea with custom message
if (statusValue_AEX == '✔') {
textareaValue = "Air Export ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_AEX);
}
if (statusValue_AIM == '✔') {
textareaValue = "Air Import ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_AIM);
}
if (statusValue_OEX == '✔') {
textareaValue = "Sea Export ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_OEX);
}
if (statusValue_OIM ==='✔') {
textareaValue = "Sea Import ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_OIM);
}
if (statusValue_WH == '✔') {
textareaValue = "Warehouse ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_WH);
}
if (statusValue_PK == '✔') {
textareaValue = "Packing ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_PK);
}
if (statusValue_RMV == '✔') {
textareaValue = "Removal ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_RMV);
}
if (statusValue_CB == '✔') {
textareaValue = "Crossborder ";
console.log('Event triggered. Status Value:', statusValue_CB);
}
if (statusValue_TR == '✔') {
textareaValue = "Transport ";
record['PDF_Field'].value = textareaValue;
console.log('Event triggered. Status Value:', statusValue_TR);
} else {
textareaValue = ""; // If checkbox is unchecked, clear the textarea
}
return event;
});
})();
Here's the field that I use: the symbol in the check box Is --> ✓