Avatar

Auto Date population

Dontae Jones

Hello,

Is it possible to have a date field auto-populate when 'Yes' is selected in a dropdown field? I'm looking to have the date field read-only and the populated date remain static.

Follow 2 followers
0

1 comment

Avatar
Yuzo Arai 0 votes

Hello Dontae,
In your case the following events should be used:

app.record.detail.show
app.record.create.show
app.record.create.change.(Dropdown Field Code)
app.record.edit.show
app.record.edit.change.(Dropdown Field Code)

Kintone Developer Program - Kintone JavaScript API List
https://developer.kintone.io/hc/en-us/articles/360009339614-Kintone-JavaScript-API-List

And since you want to auto-populate when 'Yes' is selected in a dropdown field, if/else statement should be used. The following is an example script:

(function() {
"use strict";

var events = ['app.record.detail.show',
'app.record.create.show',
'app.record.create.change.(Dropdown Field Code)',
'app.record.edit.show',
'app.record.edit.change.(Dropdown Field Code)'];

kintone.events.on(events, function(event) {

var record = event.record;

if (record['(Dropdown Field Code)']['value'] === 'Yes') {
//Input Date
}else {
//Input Empty Date
}

});
})();

Also, the following page explains about how to make a field read-only (or disabling it):

Kintone Developer Program - Enable/Disable field edits
https://developer.kintone.io/hc/en-us/articles/213149017-Record-Edit-Event#enable_disable_fields

I hope these helps!

0
Comment actions Permalink