Avatar

Is it possible to change Drop-down options?

Masa

I would like to change Drop-down options in 'app.record.create.show' event.

is it possible or not?

Follow 4 followers
0

4 comments

Avatar
Akira 1 vote

Hi Masa - there are probably two ways to achieve this, which may work in different use cases.

1) Utilize multiple dropdowns.
You can place several dropdowns in your kintone app, that have different options inside. I'm not sure from your question, what conditions are changing the Drop-down options, but you can hide/show fields depending on particular conditions using:
  kintone.app.record.setFieldShown("fieldcode","true/false")

2) Create a dropdownfield on a Space
This solution does not require you to set up a drop-down field in your app settings.
You can obtain the space field element inside your record, and use JavaScript to insert your own drop-down field into that space.
To retrieve the space element use:

var el = kintone.app.record.getSpaceElement('spaceID');

where "spaceID" is the ID you can give to the space.

After that, you can build your own dropdown field using JavaScript (you can probably find some examples on the web) and append it to the space element.

When a user selects an option from the drop-down list, make sure to insert the same value into a single-line text field (that the user cannot see). This will enable kintone to hold that data within the record.

 

Solution 2 would be a bit harder to implement, but it would allow data to be stored into one field (rather than several) which would probably help when you try to create graphs afterwards around this data.
Hope this has helped.

1
Comment actions Permalink
Avatar
Kim Verlyn Andino 0 votes

Hello Akira san,

I was checking this discussion because I would like to change the drop down options also based on my previous drop down input.I tried the Solution No. 1, and upon first selection, the correct drop down option is okay. but when I change my input the drop down value again, the changes do not reflect anymore. Is the below codes applicable for the first selection only?

Thanks for your help in advance.

0
Comment actions Permalink
Avatar
Junko Werner 0 votes

Hi Kim.

I would add more events as below, so the changes you made will be reflected in the record details and edit page.

var events = ['app.record.detail.show',
              'app.record.create.show',
              'app.record.create.change.plant',
              'app.record.edit.show',
              'app.record.edit.change.plant'];

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

});

The different types of kintone events are listed in the link below.

▼ Event Handling
https://developer.kintone.io/hc/en-us/articles/212494948-Event-Handling

Thanks.

Junko

0
Comment actions Permalink
Avatar
Junko Werner 0 votes

Sorry Kim. I forgot to tell you that I would also add the setFieldShown with false condition to hide another field as below. Thanks.

 if (plant == 'MEP'){
      kintone.app.record.setFieldShown('mes_route_name',true);
      kintone.app.record.setFieldShown('map_route_name',false);
    } else if (plant == 'MES'){
      kintone.app.record.setFieldShown('map_route_name',true);
      kintone.app.record.setFieldShown('mes_route_name',false);
    }

 

0
Comment actions Permalink