Can an app know which action button was pressed to invoke it?

Question: 
Can an app know which action button was pressed to invoke it?

Scenario:  
I have a student app with two action buttons:  [Check out a book] and [Return a book]  Both bring up the checkout app with the target field values set from the source table as expected.

Within the checkout app I have a dropdown called “What do you want to do”  [Check out a book] or [Return a book].  I use js to enable/disable the check-in and check-out fields as appropriate.  That works.

What would be nice is that when the user select the [Check out a book] action button on the student screen, the checkout screen would already have the intended “what do you want to do” selected and the screen show/hiding the appropriate fields.  If I could pass that check out/in value from student action button to the checkout apps whatdoyouwanttodo dropdown I could make it work.

Is there a way to do that?

Thanks,
Jeff

Hi Jeff,

You will need to use the ‘app.record.create.show’ event.
However, no parameter can be used to determine which app action was executed, and the add record screen of app B was displayed in this event.

You may know this, but you can specify any field to be copied in the app action.
Also, the value copied to the field can be used in the ‘app.record.create.show’ event of app B.
Therefore, it is possible to control the ‘drop-down’ field in app B in the following way.

■ Placing additional fields
○ App A (student app) →Calculated field with “1” or other value set for the formula.

○ App B (checkout app) →Number field for determining the action (field code: action determination)

■ Additional settings for app actions
○ [Check out a book] side →Add the following in the associated fields.

Calculated field with “1” set in the formula > Number field to determine the action

※No need to configure the [Return a book] side.

■ A process on App B (checkout app)

(function() {
"use strict";
kintone.events.on("app.record.create.show", function(event) {
console.log(event);

var record = event.record;

if(record.action determination.value){
record.What_do_you_want_to_do.value = "Check out a book";
} else {
record.What_do_you_want_to_do.value = "Return a book";
}

return event;
});
})();

If there are different fields to be copied in the app, and if it is possible to determine whether there is input, then there is no need to add a Calculated field.

Hopefully, this helps.

Thank you, I’ll try that.