SugarCRM - How to add "More Info" icon that displays module "Description" field on mouseover - sugarcrm

This is for SugarCRM v6.3
I need to add a "More Info" icon to the History subpanel, which, when moused-over, displays the relevant module's Description field, similar to how the More Info icon works in the Accounts ListView.
For starters I added new "History/metadata" folders to custom/modules/ and copied the subpaneldefs.php file from the core History/metadata folder.
In the subpaneldefs file, at the end of each of the module's column definitions, I added this as a test:
array ( 'customCode' => '<img src="themes/Sugar/images/info_inline.png"></img>', ),
That didn't seem to affect anything at all.
Not sure if it was just that I needed more than an image for the column to show, I then tried adding all of the code I thought was supposed to go there:
array (
'name' => 'nothing',
'module' => 'Notes',
'related_fields' => array ('id'),
'customCode' => '<a id="adspan_{$ID}" href="index.php?module=Notes&action=DetailView&record={$ID}" onmouseover="return SUGAR.util.getAdditionalDetails(\'Notes\',\'{$ID}\',\'adspan_{$ID}\');" onmouseout="return SUGAR.util.clearAdditionalDetailsCall()"><img src="themes/Sugar/images/info_inline.png"></img></a>'
),
This is, as you can see, intended for the Notes in the History subpanel, and I changed it accordingly for each of the other modules' column definitions in the subpaneldefs.php file. I modeled the code after some custom code I found that someone else here at work did for a dashlet, which shows details when an account name is moused over.
Unfortunately, that didn't work, either.
How do I accomplish this?

The only way to do this is by defining a new SugarWidget field for the field in question. Here's a good guide I found for it:
http://www.mediaart.lt/programming/sugarcrm-adding-custom-field-in-subpanel/

Related

TYPO3 automatic page creation based on TCA record

I've special requirement on my project and I need help. I am using TYPO3 8.7.8. I've a custom extension to render tag labels in frontend. We can add the tags as TCA record in backend storage folder. In the TCA record, you can tag name. My requirement is, when I save the TCA record I want to create a TYPO3 page automatically with the same name as tag in a specific position. Everytime when I add a TCA record, I need to create corresponding page automatically. Is this possible? I can use hook while saving TCA. But is there any function to create pages automatically?
After automatic page creation, I want to insert a plugin content element in that page with a specific flexform value automatically. I know this is a strange requirement, but I would like to know if it is possible or not.
Exactly, you'd trigger a hook on saving and then as next step you can use the data handler to generate the new page (and possible content).
To create the page and content, use something like the following data structure
$data = [
'pages' => [
'NEW_1' => [
'pid' => 456,
'title' => 'Title for page 1',
],
],
'tt_content' => [
'NEW_123' => [
'pid' => 'NEW_1',
'header' => 'My content element',
],
],
];
Then call the datahandler with that structure:
$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->stripslashes_values = 0;
$tce->start($data, []);
$tce->process_datamap();
Find out more in the docs at
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/Database/Index.html#data-array
and
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Typo3CoreEngine/UsingDataHandler/Index.html
Are you sure you need additional pages?
In general your problem sounds like you need one page where the plugin is inserted and where the plugin in dependency of an url-parameter (which can be converted with realurl into a path segment) shows only information depending of the selected record (tag).
If no tag is selected you can output a list with all available tags as a menu to navigate to all possible tags.
With a little effort (less than writing a hook like intended) you can add all tags to your menu.

SuiteCRM increase autocomplete time in EditView

I'm looking at a request from our customer to either lengthen the autofill or just remove it all together when adding an organisation in EditView.
e.g: https://demo.suiteondemand.com/index.php?module=Opportunities&action=EditView&return_module=Opportunities&return_action=DetailView
If you start typing into "Account Name" box 'A' it'll show all the Organisations starting with A but also it'll autofill the first result into the input box.
Is there a way to stop that autofill of the input box from happening or delay it?
Thanks
Edit: changed title to SuiteCRM
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Quicksearch/
I used the Metadata example, and it worked.
[Edit]
To expand on the answer. If you want to remove autofill from any of the boxes you need to add the 'sqsNoAutofill' to achieve this you can do the following:
In a modules editviewdefs.php (e.g. modules/(module)/metadata/editviewdefs.php) locate the name of the input you wish to change e.g:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
),
then add the following:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
'displayParams' => array (
'class' => 'sqsEnabled sqsNoAutofill'
)
),
This will stop an input box with a quicksearch drop down from autofilling.
You can also make the change to the SugarField for Parent
include/SugarFields/Fields/Parent/EditView.tpl (line 51):
<input type="text" .... class="sqsEnabled sqsNoAutofill" .....>
I hope that helps someone else.

SugarCRM - Custom Print Layout

I created a model in SugarCRM and I need to print the details view. But this must be printed with a different layout.
It must have the company logo for example, if I just wanted do print the bean information, the default print would be sufficient, but I need something closer to a report, because this info will be given to the costumer.
I would like to know if there is a way to create a printing template, and if there is, how can I create one?
Thanks for your help, if you need more information please comment.
rfnpinto
Even in SugarCRM CE you can leverage the included Sugarpdf class, which is an extension of TCPDF.
If you have SugarCRM Professional you can find examples of this in the Quotes module. If not, you're flying blind, so I can give you the gist of it.
Using the Contacts module as an example, create /custom/modules/Contacts/views/view.sugarpdf.php with contents like the following:
<?php
require_once('include/MVC/View/views/view.sugarpdf.php');
/**
* this defines the view that will drive which PDF Template we use
*/
class CustomContactsViewSugarpdf extends ViewSugarpdf{
public function display(){
$this->sugarpdfBean->process();
$this->sugarpdfBean->Output($this->sugarpdfBean->fileName,'D');
sugar_die('');
}
}
Create /custom/modules/Contacts/sugarpdf/sugarpdf.pdfout.php with contents like the following:
$contact = BeanFactory::getBean($_REQUEST['record_id']);
if(empty($contact->id)){
sugar_die('Could not load contact record');
}
$name_str = "<p><strong>Name: {$contact->name}</strong></p>";
$this->writeHTML($name_str);
$this->drawLine();
}
function buildFileName(){
$this->fileName = 'ContactPDFOut.pdf';
}
}
From there, you can print a PDF document per your format if you hit the URI index.php?module=Contacts&action=sugarpdf&sugarpdf=pdfout&record_id=1234
Once that's working in the way you want, you can add a button the Contacts Detailview to access that URI more easily. Dig into /custom/modules/Contacts/metadata/detailviewdefs.php and find the existing buttons array. It'll look something like this:
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES'
Just enhance this with your own button and hidden input
'buttons'=>array('EDIT', 'DUPLICATE', 'DELETE', 'FIND_DUPLICATES',array(
'sugar_html'=>array(
'type' => 'submit',
'value' => '(Wrongfully Hardcoded Label) Print PDf',
'htmlOptions'=>array(onclick => 'this.form.action.value=\'sugarpdf\';this.form.sugarpdf.value=\'pdfout\'')
)
)
...
The hidden array should be part of $viewdefs['Meetings']['DetailView']['templateMeta']['form'] and defined like so:
'hidden' => array('<input type="hidden" name="sugarpdf">'),
I haven't tested this recently but this is the general idea of adding custom Print PDF abilities to any particular screen within SugarCRM. TCPDF options are pretty extensive and forming the template just right is going to be very tedious, but I think once the "plumbing" is working here you'll figure that bit out, but feel free to ask followup questions.

Adding panels to editviewdefs.php via manifest file

In
SugarCRM installable changes in detailview
the question was asked about how to add a panel, using the Module Installer's manifest file to add to the the editview/detailview of an existing module without wiping out customizations previously made in the custom directory.
The answer was provided how to add fields, but not panels.
I know you could use a post_execute function called from the manifest file to edit the editviewdefs.php and detailviewdefs.php files in the
/custom/modules//metadata/
directory, but that involves making some guesses about what already exists in those files.
Does anyone know how to add panels via the manifest file (or post_execute) that incrementally adds the panel, without using php code to manually edit the editviewdefs.php and detailviewdefs.php files?
You're after the ParserFactory class, which can be used from a post_install or similar script executed as your module/package is installed. My understanding is that ParserFactory will call custom files if they're there, or stock files and adjust them appropriately and safely if not.
In your module's directory, create a subdirectory called 'scripts' and create 'post_install.php' which contains a single function post_install(). Your package dir will look something like this:
~$ find .
/LICENSE.txt
/manifest.php
/scripts/post_install.php
You use the ParserFactory like this:
<?php
function post_install(){
// $parser becomes an associative array for the metadata, similar to editviewdefs.php
require_once('modules/ModuleBuilder/parsers/ParserFactory.php');
$parser = ParserFactory::getParser('detailview', 'Accounts');
// finding the panels (which contain their fields), you can
// now add fields or additional arrays to this array, creating new panels
// (you could manipulate $parser->_viewdefs directly, but I find this easier)
$panels = array_keys ( $parser->_viewdefs [ 'panels' ] );
// place your panels back into the $parser and save
$parser->_viewdefs['panels'] = $panels;
$parser->handleSave(false);
};
Bingo - and Thank you to Matthew
I did not know where to find this and on the Sugar forum, no-one seemed to know so thank you Matthew.
So yes, it is very easy to add panels to an existing module in SugarCRM using the code that Matthew pointed out
To add a Panel called Events, in
/custom/modules/Accounts/language/en_us.lang.php
(add to this or create new file if you prefer)
add
$mod_strings = array ('LBL_DETAILVIEW_PANEL1' => 'Events',);
and then in the post_install.php file in the /scripts directory of the install package put
<?php
function post_install()
{
// Debug point - checking to see if get to post_install script
echo "Made it to the post_install script.<br />";
// Use the ParserFactory to edit the view arrays
// Fetch the existing view into an array called $view_array
require_once('modules/ModuleBuilder/parsers/ParserFactory.php');
$view_array = ParserFactory::getParser('detailview','Accounts');
// Declare the additional content
$new_content = array
(
0 => array
(
0 => array
(
'name' => 'created_by_name',
'label' => 'LBL_CREATED',
),
1 => array
(
'name' => 'modified_by_name',
'label' => 'LBL_MODIFIED_NAME',
),
),
);
// Add the new content to the desired section of the view array
$view_array->_viewdefs['panels']['lbl_detailview_panel1'] = $new_content;
//Save the layout
$view_array->handleSave(false);
return;
}
?>
(I have just put two existing fields in the new panel but you can just as easily place newly created fields (from the manifest file) into the new panel as well

SugarCRM: How do I make "first name" and "salutation" required fields on the "Convert Lead to Contact" form?

We use a customized installation of SugarCRM and I need to make a change to the "Convert Lead to Contact" form. On the form, only "last name" is marked as required, but if the user does not enter a salutation or first name, Sugar will throw an SQL error on the insert (because salutation and first name are required fields for contacts).
I've tried adding this line to "modules/Contacts/metadata/editviewdefs.php" and "modules/Contacts/metadata/quickcreatedefs.php":
array (
'name' => 'first_name',
'displayParams'=>array('required'=>true),
)
I'm trying other modifications but I can't find anything online yet on this exact problem. I will update this question with my findings. Thanks!
Update: Added "first_name" and "salutation" to the 'required_fields' array in "modules/Contacts/field_arrays.php", did not help.
Update: This is on SugarCRM 5.1. This work is happening during the upgrade to 5.1.
Update: Added the following line to "modules/Contacts/vardefs.php" the "email_and_name1" array, did not help.
'required' => 'true',
The above didn't work for me. I am using 5.2.0.
What worked for me was to edit custom/modules/{modulename}/metadata/editviewdefs.php and add:
'name' => 'first_name',
'displayParams' =>
array (
'required' => true,
),
Then quick repair/rebuild.
I appear to have figured out a solution. I created an upgrade file in "custom/Extension/modules/Contacts/Ext/Vardefs" called "custom.php". The contents of the file are below:
<?php
$dictionary['Contact']['fields']['salutation']['required'] = true;
$dictionary['Contact']['fields']['first_name']['required'] = true;
?>
After I did a "quick repair and rebuild", the salutation and first name were now required. This works for me.
Why not just make Fist Name and Salutation required fields in Leads? Then you can modify the fields to "required" right in Studio and not have to worry about upgrade security.