Hello!
I'm using Sugar CE 6.5 and I'm trying to run a function that should be changing a value of a field upon a click of a button.
Problem is, the error show is :
Here's what my metadata(custom/module//detailviewdef.php) code is :
<?php $module_name = 'UA_Quotes'; $viewdefs [$module_name] = array ( 'DetailView' => array ( 'templateMeta' => array ( 'form' => array ( 'closeFormBeforeCustomButtons' => true, 'buttons' => array ( 0 => 'EDIT', 1 => 'DELETE', 2 => array ( 'customCode' => '<input id="MonthlyQuote" title="Monthly Quote" class="button" type="button" name="Monthly Quote" value="Monthly Quote" onclick="GetPayment();">', ), ), 'footerTpl' => 'modules/UA_Quotes/tpls/DetailViewFooter.tpl', ), 'maxColumns' => '2', 'widths' => array ( 0 => array ( 'label' => '10', 'field' => '30', ), 1 => array ( 'label' => '10', 'field' => '30', ), ), 'useTabs' => false, 'tabDefs' => array ( 'LBL_EDITVIEW_PANEL2' => array ( 'newTab' => false, 'panelDefault' => 'expanded', ), ), 'include' => array ( 0 => array ( 'file' => 'custom/include/clickPayment.js', ), ), ), 'panels' => array ( 'lbl_editview_panel2' => array ( 0 => array ( 0 => 'name', 1 => array ( 'name' => 'ua_contracts_ua_quotes_1_name', ), ), 1 => array ( 0 => array ( 'name' => 'monthlystart_c', 'label' => 'LBL_MONTHLYSTART', ), 1 => array ( 'name' => 'quote_stage', 'studio' => 'visible', 'label' => 'LBL_QUOTE_STAGE', ), ), 2 => array ( 0 => array ( 'name' => 'monthlydeadline_c', 'label' => 'LBL_MONTHLYDEADLINE', ), ), ), ), ), ); ?>
Also, here's what the JS(clickPayment.js - custom/include) code is :
function GetPayment(){ var pathArray = window.location.href.split("="); console.log(pathArray[3]," - your Record ID"); $.ajax({ type: 'POST', url: "custom/include/changestatus.php", data:{recordID: pathArray[3]}, success:function(fdata){ console.log("Customer Status Change"); location.reload(true); }, error: function(fdata) { // if error occured console.log(" NA "); } }); }
and the PHP called from JS (changestatus - custom/include) code :
<?php $myrecordID = $_REQUEST['recordID']; $focus = new UA_Quotes(); $focus->retrieve($myrecordID); $focus->quote_stage_dom = 'Paid'; ?>
Am I doing something wrong here? perhaps the file's path? or how I called the JS? or, are there any alternative solutions to this?
Thanks and help is much appreciated!
Seems like the clickPayment.js is not properly loaded, does the file have the proper file permissions and you ran a Quick Repair to update the cache? Can you check in Chrome > Developer Tools if the code was added or add an alert("test"); to the file to see if it is active?