SugarCRM — Conditional Actions

Say you need to hide certain actions in Sugar depending on the status of a field, I’ve come across a great snippet of code from an awesome comment by Felix Nilam on the SugarCRM forums and wanted to show you a brief snippet of how it could work. Make sure to call it before render, otherwise I had issues with this.meta.buttons already having rendered. ({ extendsFrom: 'RecordView', initialize: function (options) { app.view.invokeParent(this, {type: 'view', name: 'record', method: 'initialize', args:[options]}); this.before('render', this.mycustom_button_visibility, this); this.before('render', this.mycustom2_button_visibility, this); }, mycustom_button_visibility : function() { if(typeof this.model.get('some_field') != 'undefined' && this.model.get('some_field') != 'some_value') { this.hide_button('some_button_name'); } }, mycustom2_button_visibility : function() { if(typeof this.model.get('some_second_field') != 'undefined' && this.model.get('some_second_field') != 'some_value') { this.hide_button('some_second_button_name'); } }, hide_button: function(name) { var button_sel = ''; var button_index = ''; // find the buttons index for the share button _.find(this.meta.buttons, function(bn, idx) { if(bn.name == 'main_dropdown') { button_sel = idx; _.find(bn.buttons, function(bbn, idx_bbn) { if(bbn.name == name) { button_index = idx_bbn; return true; } }); return true; } }); if(button_sel != '' && button_index != '') { //remove the meta this.meta.buttons[button_sel].buttons.splice(button_index, 1); } } }) Props to Felix for the snippet and I hope this helps others. ...

October 15, 2015 · Shane Dowling

Bioinformatics/Rosalind — Skeleton Generator

Working through part 4 of my Cousera Bioinformatics specialisation, I decided to write a generator that creates a standardised approach to structure, write and test your algorithmic code. It also works for Rosalind problems. Explanations are in the README. If you have any issues or are confused by anything, feel free to get in touch! You can find the code here.

September 27, 2015 · Shane Dowling

Tiddlywiki to Org-Mode

Okay, I swear this is the last document conversion script I’m writing this year. I’ve been on a bit of a rampage to move all of my life in Emacs Org-Mode and converting all of my Tiddlywiki notes into Org mode has been on my list for a while. Thankfully both formats are pretty simple so the script was fairly straightforward. You can find it here, simply fill in the folder locations and give it a run. ...

August 31, 2015 · Shane Dowling

OSQA to Tiddlywiki

Recently I’ve been trying out Tiddlywiki as an alternative to Evernote. I decided to try convert my existing OSQA install to Tiddlywiki as I’m travelling a lot and don’t always have access to my servers via the internet. Here’s a python script I wrote that might help anyones trying to do the same. You can find it here on github. Any questions or queries, just let me know!

July 27, 2015 · Shane Dowling

Verify you're hidden with conky

I run a few scripts to ensure my identity stays hidden day to day on my laptop. Here’s a few conky scripts to verify things are as they should be. VPN Because I don’t always know my ip or what my VPN’s ip is, I wanted conky to display the location I currently appear at from my VPN. If the location was the same as where I physically am, something’s gone wrong. To implement this, I wrote a python script and using ipinfo.io grab my location and print it to conky. ...

July 26, 2015 · Shane Dowling

SugarCRM 7 — Adding an action to the listview headerpanel

This tutorial should show you how to add a custom button/action that will appear across all modules. It’s a little similar to this tutorial with a few changes to how the button gets rendered and the actions get called. 1. Adding the button to the headerpanel Firstly you’ll need to create a new folder to store the headerpane actions, so create this folder in the sugarcrm root directory custom/clients/base/views/list-headerpane/. Then create the file list-headerpane.php with this content. This will add a button next to the Create button for all modules. ...

July 25, 2015 · Shane Dowling

SugarCRM — Prevent currencies getting overridden

SugarCRM has some neat features involving currency rates, but one of the more annoying ones is that Sugar will automatically update the base rate every time you save a record with a currency field attached. This can be fairly annoying default behaviour if you wish to maintain the correct record value at the time of sale. The problem Say for example you have a custom module Books and your systems base currency is USD. You sell a book for 10 Euros at 11 dollars(the currenct change rate). If say a few weeks later you wanted to change the status of the Book to say, note down that the invoice was received and the exchange rate in that time has changed drastically. When you hit save Sugar would re-calculate the Euro value again(and despite the item being sold for 10 Euros originally the exchange rate has now changed and Sugar shows say 12 Euros, which is completely inconsistent with what you’ve invoiced. ...

April 16, 2015 · Shane Dowling

SugarCRM 7 — Roll SugarCRM with Docker

I find trying to replicate the SugarCRM environment locally a real pain. One of the main issues is simply that Sugar requires such old versions of PHP to be installed, especially compared to other web projects I have that implement the latest/greatest versions of PHP. Running multiple PHP versions simultaneously can be a pain. One solution is to use Vagrant but I find that too heavy for my needs, so I gave docker a go and found it a much faster/elegant solution. ...

April 7, 2015 · Shane Dowling

Setting up git with Rescuetime highlights

Recently I’ve written on another site how I use Rescuetime to provide metrics on my overall productivity that I can review each week. One useful feature I noticed was Rescuetime highlights, which gives you a good overview of your accompishments throughout the day. The first thing I wanted to add to this (obviously) was git commits. Luckily it turns out someone had already thought of this and implemented it. The script itself is here, I’m just going to reproduce it below. ...

February 15, 2015 · Shane Dowling

Bulletproof productivity

Over the last few months I’ve been trying different ways to increase my productivity, specifically during work hours. From todo lists to pomodoro’s, xeffect cards, the autofocus method and even back to GTD. I’ve noticed a pattern with a lot of these techniques. They all require a pile of maintenance and none of them actually give you much in terms of positive feedback. When you mark a task off a list, you’re often not getting the satisfaction of completion because that task is in the middle of a huge pile of other tasks you have yet to face. These lists goal to complete, all lists and systems have done is given me two problems to solve. The Pomodoro technique especially, the amount of over-head and tracking you need to do just to discover productivity trends is painful. How off were your estimates, how many interruptions did you log last Tuesday, it’s all a bit messy and overwhelming after a while, and difficult to maintain. ...

February 14, 2015 · Shane Dowling