Disruption & Update Information Japanese Chinese

kintone plugin series

Boost! Events

The Boost! series plugins allow you to use JavaScript to add custom processing for events that occur in each plugin. For details on each event type, please refer to the following:

Event Handling

Introducing how to attach handlers to various events.

Register Event Handlers

Syntax
kb.event.on(type, handler)
Parameters
Parameter Value Description
type String or Array of Strings The event type or array of event types, to which the event handler will bind to.
handler Function(Object)

The handler that will run when the event is triggered.

By returning a Promise object in the event handler, it waits for the asynchronous process to complete before starting the next process.

Response
None
Sample
(() => {
	"use strict";
	const handler = (event) => {
		console.log(event);
	};
	kb.event.on('kb.view.load', handler);
})();

Remove Event Handlers

Syntax
kb.event.off(type, handler)
Parameters
Parameter Value Description
type String or Array of Strings The event type or array of event types, to which the event handler is bound to.
handler Function(Object)

The handler that will be removed from the specified event type(s).

Response
None
Sample
(() => {
	"use strict";
	const handler = (event) => {
		console.log(event);
	};
	kb.event.on('kb.view.load', handler);

	kb.event.off('kb.view.load', handler);
})();

Event Object Actions

Introducing the actions you can perform on the event object.

Overwrite field values

If the event handler overwrites values in the fields of the record object and returns the event object, the fields of the record are updated with those values in the object.

Sample
(() => {
	"use strict";
	kb.event.on('kb.change.field_1_', (event) => {
		const record = event.record;
		if (record.field_1_.value=='')
		{
			record.field_2_.value=='option1';
		}
		return event;
	});
})();

Run Lookup fields

If the event handler enters true to the lookup property of the lookup field and returns an event object, it will automatically retrieve those lookup fields.

To clear the lookup field, empty the value property and enter true for the lookup property.

Sample
(() => {
	"use strict";
	kb.event.on('kb.edit.load', (event) => {
		const record = event.record;
		if (!record.field_3_.value)
		{
			record.field_3_.value=1;
			record.field_3_.lookup=true;
		}
		return event;
	});
})();

Stop subsequent processing

If the event handler inputs true to the error property and returns an event object, the operation involving subsequent processing is cancelled.

Sample
(() => {
	"use strict";
	kb.event.on('kb.create.submit', (event) => {
		const record = event.record;
		if (record.field_1_.value=='')
		{
			kb.alert('No value entered.');
			event.error=true;
		}
		return event;
	});
})();