Cancel button on create action

Hi!
Can someone point me where in the code is generated the CANCEL button of create action for module.
I have strange behaviour that for some modules the cancel button action is index, but for some is DetailView. On the latter that causes an error because there is no id for the detail view.
This is probably my error somehow but I need to find portion of source code which handles this to find way is this happening.

Best regards,

Default buttons are defined in include/Smarty/plugins/function.sugar_button.php. But you should never need to touch this, something else is wrong with your SuiteCRM installation.

Have you tried doing a quick repair and rebuild?

Thanks for the reply,

yes I have done repair and rebuild more than once.
We have done various changes in our installation and I can’t track in git tree the change which caused this. So I’m looking a starting point for debugging.

Hi! I have managed to fix this behaviour.
It was caused by including this bugfix in our code: https://github.com/salesagility/SuiteCRM/pull/898
The issue was that for some modules eg. Leads, Quotes…, create button is passing ‘DetailView’ as return action but there is no ID of record, and above part of code generates cancel button by setting action by return_action parameter which in this cases is detail view.
After adding condition which checks if return action is detail view and there is no record id we set action as ‘index’ the issue is resolved.