Showing posts with label SugarCRM. Show all posts
Showing posts with label SugarCRM. Show all posts

Tuesday, December 31, 2019

My new blog

My name is Ken Brill.  I live in central Missouri about 100 miles south of St. Louis. My wife and I run a small 30-acre hobby farm here in Missouri, and I work as a developer from a small, dark corner in my basement.  Out here we only have satellite Internet (Viasat) so that's fun.  They advertise 25Mbs but I rarely see anything better than 12Mbs.  It does the job but I miss my cable modem sometimes.

On the farm, we raise about a dozen goats and sheep, 2 cows, 3 horses, 7 dogs (ranging from a Chihuahua and Maltese to a pair of Great Pyrenees, 6 cats of no discernible use, 4 kids (all girls), and a few dozen Chickens, Guinea fowl, Peacocks, Turkeys, and Ducks.  We have been at it for 5 years now so we are still learning but it's a lot of fun when it's not freezing outside.




The last 12 years I have specialized in SugarCRM.  I began with version 2.5 when a small company I worked for started using it and I have been working on SugarCRM ever since.  I had my own consulting company for a few years where I sold a product called 'Sugar Fully Loaded' that was essentially the SugarCRM CE product with several popular add-ons already loaded and merged (no such thing as upgrade-safe back then).  I spent 9 years after that working at SugarCRM in different roles and now I work remotely as a senior developer on an enterprise level installation and we are getting ready to roll out version 7.10 next year.

Wednesday, March 27, 2019

Adding Audit Logs to Reports

My users had a need to query the audit log for various modules in ways that the current built in system would not allow.  Now I could create advanced report after advanced report but really I hate making advanced reports. So I added myself a JIRA task to create some way of reporting on the Audit Logs.

All the files are available for download from the GitHUB link at the end of this post.

This was my list of criteria for this project
  1. I need a way to report on any modules audit log
  2. I need a way that allows a manager to create their own reports
  3. That method has to be familiar to them already (this was really me saying I wanted it in the Reports module)
  4. It must not allow editing of Audit Logs in any way
  5. It must be fast over millions of records (some of our audit logs are huge)
  6. It must translate all the raw data back into English
  7. It must allow our system admins to include that new audit_events table data in the reports
  8. It cant break the current Audit code

Monday, October 8, 2018

Make a new team the primary team with confirmation alert

Where I work we use Tasks to pass around work from one department to the next.  So a Lead might come in and a Task on that Lead is assigned to the Sales team.  Once the Sales team finishes whatever they need to do they assign the Task to the Legal team.  The Legal team then passes it to the Order Management team and so on.

One of the issues with this was that we couldnt preadd the teams as tasks take their own path sometimes and it muddied reports when we did that.  So each team needed to add the next team to the Task and mark it as Primary. 

Well, as with most manual workflows, it didn't always get marked as primary.  So I came up with the code below to ask the user, after they add a team, if they want to make it the primary team and if they say yes, then mark it as primary.  It took forever to figure out how to tell if a team had been added, and I dont really like this solution but it worked the best so I went with it.

So first the code, it just goes in the record.js of whatever module you want to add this to.



Then add a line to the language file custom/include/language/en_us.lang.php that reads.  Notice how I am filling in the 'TeamName' variable with the app.lang.get() code in the record.js file.



With this code in place (after a QR&R of course) when a new team is added, the system will ask the use if they want that team marked as primary.  If they say yes then it will be.

Tuesday, April 17, 2018

User names in the sugarcrm.log instead of IDs

So normally the sugarCRM log file is filled with lines like this

Mon Apr 16 07:02:12 2018 [15900][412b8e70-febc-11e6-934a-52d504b662cb][FATAL] No Links found for relationship tasks_activities_1_tasks
Mon Apr 16 07:02:12 2018 [15900][420703ed-f2bc-e3f4-f906-566ef6f1e16d][FATAL] No Links found for relationship accounts_accounts_1
Mon Apr 16 07:02:12 2018 [15900][41a5d4a2-c01b-11e7-88b5-52d504b662cb][FATAL] No Links found for relationship cases_cases_1

Usually I am looking for an entry from a particular user so GUIDs are hard for old human eyes to read.  Even with FIND its a pain.  So I wrote this


This writes out a script and, when run, will rewrite the sugarcrm.log file with user_names instead of IDs.

So to use this you need to
  1. Copy this code to the root SugarCRM directory
  2. run it (php -f updateLog.php)
  3. Update the permissions on the file it creates (chmod 777 updateLog.sh)
  4. Run the script (./updateLog.sh)
Of course this only works on Linux or Mac and maybe the Linux Shell in windows, not sure abou thtat.  But anyway I like it and I hope up do to.

This could also be done in real time by overriding include/SugarLoggger/SugarLogger.php and changing the bit of code that write the line to the log file.  I can show that if anyone needs it, just ask.

Sunday, January 28, 2018

Developer Centric Logging

A few weeks ago I wrote some posts about overriding the CRON handler and I showed code about Developer Communication.   Since then I have talked to a few people and they all wanted to know what that cryptic function call did so I thought I would look into releasing it.   When I looked at the code I realized that I could not release it as it was crap.  So I took a week and rewrote it into this.  What we have here is a custom logger.  I found scant few examples of custom loggers on the internet so I hope someone finds this useful.

I think it adds all the missing pieces into SugarCRM's SugarLogger function like timers, headers, line tracing, email, and notifications.

Friday, January 19, 2018

Use Rows & Columns reports in Dashlets



I have been thinking about this dashlet for about 7 years.  Its been on my 'to-do' list for probably 4 years.  It found its way to the top of that list January 1st.  I finally coded it this week.  I have been dreading it, the Reports module can be difficult to decode let alone customize.  But, after all of that it was far easier than I had imagined.  I really only had 3 issues.

Sunday, January 14, 2018

Overriding MysqliManager.php

Overriding the stock SQL Managers


It took me a while to figure out how to override the core MysqliManager class so that I could add some code to email me the SQL errors that usually just go to my logs.  At first I tried just creating the custom file, expecting it to be read like others I had created, but I found that you actually  have to tell the system to use your custom class in the config_override.php file like this

Customizing cron.php

Customize cron.php without replacing the stock file

I wanted to add functionality where I would be emailed if any of the cron jobs failed for any reason.  I found in $sugar_config there is an option to override the cron class that is used to run scheduled jobs and normal cron related things. You can add it to the config_override.php file like this...

Adding custom, global, upgrade-safe PHP functions to SugarCRM

PHP Functions
This falls into the category of hard to find.  It is clearly outlined in the SugarCRM Developers Guide but I have never seen anyone use it.  There were no postings on the message boards about it and I simply stumbled upon it one day.  I wanted to consolidate some code written by others, there were functions that were repeated over and over again in module after module.  So I wanted to find a way to easily move these functions into someplace that was shareable by all modules and was upgrade safe.

Add a JQuery plugin style to a SugarCRM field - Checkboxes to Switchery

Switchery
This is the first in a series where I will show ways to add JQuery custom UI elements to SugarCRM views.   This is fairly easy to do for most JQuery plugins.



In this post we are going to use Switchery.  This JQuery plugin will convert normal checkboxes to iOS style buttons as shown above.   It has a few options but in this first part we are just going to stick to the defaults.  First we have to get the plugin loading into SugarCRM.  We could use the JS loader plugin they released a while back but I had issues with that loading the script multiple times so we are going to stick to the tried and true JSGroupings for this one.