Hey all, I’ve been trying to create a custom button in the AOS_Invoices modules list view. The module does NOT have a views/view.list.php file defined and I found the following article that looks like just the thing I needed:
https://www.sugaroutfitters.com/blog/how-to-add-buttons-to-views-in-sugarcrm
I tested the very simple example in that article and it worked as expected, the menu button appeared and when clicked it displayed an alert window with the message Hello World.
I have attempted to customise the code so that when clicked it will parse the data to an entrypoint I’ve defined. After saving the new code I continually get an error in my browser console: error adding script SyntaxError: “missing ) after argument list” Although the error sounds simple enough to fix, I for the life of me can’t figure out where the ) is missing and/or which quotation marks need to be added/moved to ensure the closing ) is recognised. The complete code I have created is as follows:
<?php
class InvoiceButtons {
function add()
{
switch ($GLOBALS['app']->controller->action)
{
case "listview": // Add buttons to List View
$button_code = <<<EOQ
<script type="text/javascript">
$(document).ready(function(){
var button1 = $('<li><a href="javascript:void(0)" onclick="return sListView.send_form(true, 'AOS_Invoices', 'index.php?entryPoint=myentrypoint&func=myfunction','Please select at least 1 record to proceed.')">Custom Function</a></li>');
// Add item to "bulk actions" dropdown button on list view
$("#actionLinkTop").sugarActionMenu('addItem',{item:button1});
});
</script>
EOQ;
echo $button_code;
break;
}
}
}
I believe the problem is in this line of code:
var button1 = $('<li><a href="javascript:void(0)" onclick="return sListView.send_form(true, 'AOS_Invoices', 'index.php?entryPoint=myentrypoint&func=myfunction','Please select at least 1 record to proceed.')">Custom Function</a></li>');
specifically in this portion
(true, 'AOS_Invoices', 'index.php?entryPoint=myentrypoint&func=myfunction','Please select at least 1 record to proceed.')
If ANYONE could give me a pointer into where the single/double quotes should be changed/added so that the closing ) is recognised I would be eternally grateful.
Thanks for your time and patience