app.record.detail.process.proceed event fires multiple times after advancing Process Management Status

2 followers Follow
Avatar
Abdul Karmach

Hello, I don't believe this event should be firing multiple times for one click. This video shows the basic problem: https://goo.gl/mNUyQf

This video explains my ultimate goal: https://goo.gl/WoDC18

This is my code:

// Process Management Alert messages
kintone.events.on("app.record.detail.process.proceed", function (event) {
//Get value of current status (before proceeding)
console.log(event);
var action = event.action.value;

if (action === "Paperwork Complete") {
//Display Sweet Alert message
return swal({
title: "Are you sure?",
text: "Please ensure all Resident Paperwork has been received before proceeding.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, comfirmed"
}).then(function (result) {
if (result.value) return event;
else return false;
});
}

// Do nothing for other actions/statuses
return (event);

});
0

3 comments

Avatar
Junko Werner 0 votes
I have tried your coding but I was unable to get the same issue you had like the event firing multiple time. But as your video shows, the same log is input at console multiple times, so the event have incurred more than once.

Regarding the error message on the console, I was able to get the error about "then" that cannot be used. Probably, to change the process to return swal, there might be some additional process besides the one you mentioned here.
Could I ask  two additional info?
1. The setting for Process Management
2. The whole code

 

0
Avatar
Abdul Karmach 0 votes

Junko, after just now having a fresh look at my code, I see that my function for app.record.detail.process.proceed was accidentally inside of my app.record.detail.show function, which explains the additional fires. My script is about 100 lines and I hadn't noticed before. Time to tidy things us by separating everything into outer scope functions and call from within the Kintone events. Everything is working exactly as expected now. Sorry to have wasted your time.

0
Avatar
Junko Werner 0 votes

No worries! I am glad that you found another event was causing the problem previously and everything worked out now.

0

Please sign in to leave a comment.