Avatar

Set Up Lookup Filter from Javascript

Afief

Dear Developers,

As title said, when I on a create page with a Lookup Field, I want to set that lookup Filter manually with javascript instead of setting it up from kintone app settings.

So when user want to lookup, the lookup already display the filtered record as desired, the filter itself should be able to change, dynamically based on a condition that I wrote on javascript.

Is there any way to do that? If so, please let me know.

Thank you in advance!

Follow 2 followers
1

1 comment

Avatar
Yuzo Arai 2 votes
Hello Afief!
 
So what I understand, basically you want the Lookup Field to do its job automatically based on the value that you write on a javascript upon creating a record or editing a record.
 
Then the script can be something like this:
(function() {

"use strict";

kintone.events.on(['app.record.create.show','app.record.edit.show'], function(event) {

var record = event.record;

record['Lookupfield']['value'] = 'XXX'; // Lookup Field Value

record['Lookupfield']['lookup'] = true; // When this is true, it automatically looks up upon the value is entered

return event;

});

})();
 
I hope this helps.
2
Comment actions Permalink