How to override the 'Schedule Meeting' Button in an Activities Subpanel

I’m trying to override the SugarWidgetSubPanelTopScheduleMeetingButton of an Activities subpanel by creating a custom button that extends SugarWidgetSubPanelTopButtonQuickCreate.

The new button works, but its label is lost.

The original button outputted the following html:

<a id="Activities_schedulemeeting_button">Schedule Meeting</a>

however, the new button loses the reference to ‘schedule meeting’ and outputs the following :

<a id="Activities__button"></a>

The ‘onsubmit’ and other properties are set in \custom\include\generic\SugarWidgets\MyNewButton.php, but i cannot work out how the ID of the ‘a’ tag is set.

I don’t see <a> tag there, I see a form (which matches the code in SugarWidgetSubPanelTopScheduleMeetingButton)

<form onsubmit="return SUGAR.subpanelUtils.sendAndRetrieve(this.id, 'subpanel_activities', 'Loading...');" action="index.php" method="post" name="form" id="formformMeetings">
<input type="hidden" name="target_module" value="Meetings">
<input type="hidden" name="account_id" value="cbffdd8e-1e55-97b0-96a0-58f76ffe9bfd">
<input type="hidden" name="account_name" value="Test Account"><input type="hidden" name="to_pdf" value="true"><input type="hidden" name="tpl" value="QuickCreate.tpl"><input type="hidden" name="return_module" value="Accounts">
<input type="hidden" name="return_action" value="DetailView">
<input type="hidden" name="return_id" value="cbffdd8e-1e55-97b0-96a0-58f76ffe9bfd">
<input type="hidden" name="record" value=""><input type="hidden" name="action" value="SubpanelCreates">
<input type="hidden" name="module" value="Home">
<input type="hidden" name="target_action" value="QuickCreate">
<input type="hidden" name="parent_type" value="Accounts">
<input type="hidden" name="parent_name" value="Test Account">
<input type="hidden" name="parent_id" value="cbffdd8e-1e55-97b0-96a0-58f76ffe9bfd">
<script type="text/javascript" src="include/SugarFields/Fields/Datetimecombo/Datetimecombo.js?v=Q2jD1nua69ue5PEM9dwhzg"></script>
<script type="text/javascript" src="cache/include/javascript/sugar_grp_jsolait.js?v=Q2jD1nua69ue5PEM9dwhzg"></script>
<input title="Create" accesskey="N" class="button" type="submit" name="Activities_schedulemeeting_button" id="Activities_schedulemeeting_button" value="Schedule Meeting">
</form>

The <a> i am referring to is within the form tag.

Here is the result i see when i use the original button (you can see the <a> tag at the end of the first line) :

<form onsubmit="return SUGAR.subpanelUtils.sendAndRetrieve(this.id, 'subpanel_activities', 'Loading...');" action="index.php" method="post" name="form" id="formformMeetings">*<a id="Activities_schedulemeeting_button">Schedule Meeting</a>*
<input type="hidden" name="target_module" value="Meetings">
<input type="hidden" name="opportunity_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<input type="hidden" name="opportunity_name" value="h"><input type="hidden" name="to_pdf" value="true"><input type="hidden" name="tpl" value="QuickCreate.tpl"><input type="hidden" name="return_module" value="Opportunities">
<input type="hidden" name="return_action" value="DetailView">
<input type="hidden" name="return_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<input type="hidden" name="record" value=""><input type="hidden" name="action" value="SubpanelCreates">
<input type="hidden" name="module" value="Home">
<input type="hidden" name="target_action" value="QuickCreate">
<input type="hidden" name="parent_type" value="Opportunities">
<input type="hidden" name="parent_name" value="h">
<input type="hidden" name="parent_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<script type="text/javascript" src="include/SugarFields/Fields/Datetimecombo/Datetimecombo.js?v=G3eZjN5ovcZYhu440tk2pQ"></script>
<script type="text/javascript" src="cache/include/javascript/sugar_grp_jsolait.js?v=G3eZjN5ovcZYhu440tk2pQ"></script>
<input title="Create" accesskey="" class="button" type="submit" name="Activities_schedulemeeting_button" id="Activities_schedulemeeting_button_old" value="Schedule Meeting" style="display: none;">
</form>

However, when i override the button (but without changing any code within it), i get the following; and you can see that the ID of the <a> tag (and its content) has changed and the words ‘Schedule meeting’ have been omitted.

<form onsubmit="return SUGAR.subpanelUtils.sendAndRetrieve(this.id, 'subpanel_activities', 'Loading...');" action="index.php" method="post" name="form" id="formformMeetings"><a id="Activities__button"></a>
<input type="hidden" name="target_module" value="Meetings">
<input type="hidden" name="opportunity_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<input type="hidden" name="opportunity_name" value="h"><input type="hidden" name="to_pdf" value="true"><input type="hidden" name="tpl" value="QuickCreate.tpl"><input type="hidden" name="return_module" value="Opportunities">
<input type="hidden" name="return_action" value="DetailView">
<input type="hidden" name="return_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<input type="hidden" name="record" value=""><input type="hidden" name="action" value="SubpanelCreates">
<input type="hidden" name="module" value="Home">
<input type="hidden" name="target_action" value="QuickCreate">
<input type="hidden" name="parent_type" value="Opportunities">
<input type="hidden" name="parent_name" value="h">
<input type="hidden" name="parent_id" value="901895af-99eb-7e6a-51b7-5e40516bed20">
<script type="text/javascript" src="include/SugarFields/Fields/Datetimecombo/Datetimecombo.js?v=BfqgXnOAZ_YWIUIXc9BanQ"></script>
<script type="text/javascript" src="cache/include/javascript/sugar_grp_jsolait.js?v=BfqgXnOAZ_YWIUIXc9BanQ"></script>
<input title="" accesskey="" class="button" type="submit" name="Activities__button" id="Activities__button_old" value="" style="display: none;">
</form>

but i can’t see were the <a> tag is added in SugarWidgetSubPanelTopScheduleMeetingButton

I think some of what you’re seeing must be coming from some previous customization you have.

I don’t see any <a> tag there in my system…

Which makes sense, because it’s just a form, and a <button>, not an HTML link, and your <a> tag doesn’t even have a target, so it won’t do anything…

hmm, yes the button works regardless, its just that it has not label. ill look through customisation to see if i can find the culprit.

i deleted the entire custom folder (and don’t recall making any non upgrade safe changes) but unfortunately the issue remains for me with 7.11.10, Sugar Version 6.5.25 (Build 344).

I don’t know what else you could try. Maybe go through all the relevant repairs in Admin & Repairs?

wohoo

i needed to add the custom button to the $class_Map array in the getClassFromWidgetDef function in layoutManager.php.

For some reason i cant override the language of Activities module, but i can set the button label manually in the layout anager.

Ok :cool: !

If you can post your detailed solution here for others, that would be great. Thanks!

unfortunately the solution is not upgrade safe.

i thought i could override the layoutManager via the custom folder in the same way the buttons are overridden. However looks as though its not possible to override the layout manager.

So although i can substitute the button in a safe way, setting the label is more of a problem. Neither the Activities language file or the layout manager appear to check the custom folder

I wanted to override the ‘Schedule Meeting’ button on the ‘Activities’ SubPanel of an Opportunity, in order to pass additional fields from an Opportunity when quick creating a Meeting. I have it working but its not upgrade safe:

  1. Created the new custom button:

    Copy
    include/generic/SugarWidgets/SugarWidgetSubPanelTopScheduleMeetingButton.php
    to custom/include/generic/SugarWidgets/SugarWidgetSubPanelTopScheduleMeetingButton_c.php

    Edit the new file and change its class name to match the filename of SugarWidgetSubPanelTopScheduleMeetingButton_c

    Add the fields to be passed, in the display function of the new file; for example :

public function display($defines, $additionalFormFields = null, $nonbutton = false)
{
$focus = new Meeting;
if (!$focus->ACLAccess(‘EditView’)) {
return ‘’;
}
$additionalFormFields[‘description’] = $defines[‘focus’]->description;
return parent::display($defines, $additionalFormFields);
}

At this point the new button was working but it lost its label and appeared a blank button with no label.
To fix this I needed to add the new button to the class_map array in LayoutManager.

  1. Open the file include/generic/LayoutManager.php and add the button definition to the $class_map array within the getClassFromWidgetDef() function.

public function getClassFromWidgetDef($widget_def, $use_default = false) {
‘SugarWidgetSubPanelTopScheduleMeetingButton_c’ => array(
‘widget_class’=>‘SugarWidgetSubPanelTopScheduleMeetingButton_c’,
‘module’=>‘Meetings’,
‘title’=>‘LBL_NEW_BUTTON_TITLE’,
‘access_key’=>‘CUSTOM BUTTON NAME’,
‘form_value’=>’’,
‘ACL’=>‘edit’,
),

  1. Tell the Activities sub panel to use the button
    Open custom/modules/Opportunities/metadata/subpaneldefs.php and make the following change

$layout_defs[‘Opportunities’] = array(
‘subpanel_setup’ => array(
‘activities’ => array(
‘order’ => 10,
‘sort_order’ => ‘desc’,
‘sort_by’ => ‘date_due’,
‘title_key’ => ‘LBL_ACTIVITIES_SUBPANEL_TITLE’,
‘type’ => ‘collection’,
‘subpanel_name’ => ‘activities’, //this values is not associated with a physical file.
‘module’ => ‘Activities’,
‘top_buttons’ => array(
array(‘widget_class’ => ‘SubPanelTopScheduleMeetingButton_c’),
),

The button worked correctly now and the label shows as CUSTOM BUTTON NAME.

I know the changes to include/generic/LayoutManager.php are not upgrade safe, but at the moment it works for me.

I 'm sure there will be a much easier way to achieve this, or an upgrade safe way, if anyone can help?

2 Likes