Save Event

Save Event - app.record.create.submit

An event triggered when the save button is clicked on the record create page.
This event does not hold the Record ID in the event object - use the Save Success Event instead to obtain the Record ID of the created record.

Function

Desktop

app.record.create.submit

Mobile

mobile.app.record.create.submit

Properties of the Event Object

PROPERTY TYPE DESCRIPTION
appId Number The App ID.
record Object A record object that holds data inputted by the user.
type String The event type.

Cancel Actions

Actions can be cancelled by doing one of the following:

Available Event Object Actions

Running actions after waiting for asynchronous operations to finish

By returning a kintone.Promise object, you can run actions after waiting for asynchronous operations to finish. If an error occurs and the Thenable object is rejected, the event will be cancelled.

Sample Request using the kintone.Promise object returned by the kintone.api()

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
kintone.events.on('app.record.create.submit', function(event) {
  var record = event.record;
  var companyName = record.company_name.value || '';
  var masterAppId = 21; // App ID of a different app
  var query = 'company_name="' + companyName + '"';
  var params = {app: masterAppId, query: query};

  return kintone.api('/k/v1/records', 'GET', params).then(function(resp) {
    // Check that the company name exists in the master app
    if (!resp.records.length) { // Set an error message on the field
      record.company_name.error = 'Company name does not exist.';
    } else { // The record will save when the alert window closes
      alert('Found company');
    }
    return event;
  }, function(resp) { // Dealing with errors received by the system
    var errmsg = 'There was an error when retrieving the data.';
    if (resp.message) {
      errmsg += '\n' + resp.message;
    }
    alert(errmsg);
  });
});

Sample Request using the kintone.Promise Constructor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
kintone.events.on('app.record.create.submit', function(event) {
  var record = event.record;
  var companyName = record.company_name.value;
  var masterAppId = 21; // App ID of a different app
  var query = 'company_name="' + companyName + '"';
  return new kintone.Promise(function(resolve, reject) {
    var params = {app: masterAppId, query: query};
    kintone.api('/k/v1/records', 'GET', params, function(resp) {
      resolve(resp);
    });
  }).then(function(resp) {
    if (!resp.records.length) {
      record.company_name.error = 'Company name does not exist.';
    }
    return event;
  });
});

Limitations