Accessing PHP variable in .tpl

SugarCRM, SuiteCRM Navin Rakhonde
Sometimes situation may arise when you want some PHP code in tpl. Following piece of code will show how to achieve this. {php} global $current_user; $this->_tpl_vars['current_user_email'] = $current_user->email1; {/php} Now use 'current_user_email' variable as follows in tpl. <input type="text" id = "current_user_email" name="current_user_email" value='{$current_user_email}'> Hope you find this blog post helpful.…
Read More

Get date plus or minus today

SugarCRM, SuiteCRM Navin Rakhonde
Several times I have came across same requirement of getting few days back from today, or few days after today. SugarCRM comes with few very handy date utility functions, and there is one which does the job! global $timedate; $today = $timedate->getInstance()->nowDbDate(); // Today $earlier = $timedate->asDbDate($timedate->getNow()->modify("-30 days")); // 30…
Read More

SugarCRM REST API example with javascript

SugarCRM, SuiteCRM Navin Rakhonde
This blog post explains how to login to SugarCRM instance through javascript Let's have an example of REST API through JavaScript. Create an html file to include javascript, We will require jquery. Provide correct Javascript path in HTML file<ANYNAME>.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang='en'> <head> <meta http-equiv="Content-Type"…
Read More

Show message after redirection

SugarCRM, SuiteCRM Navin Rakhonde
Let's alert user a message after redirection to any view. Following piece of code will show a message at the top of the view you have redirected user to. SugarApplication::appendErrorMessage('You have been redirected here because ....'); If you dont know how to redirect user to a certain view, SugarApplication::redirect('index.php?module=<MODULE_NAME>&action=<ACTION>&record=<RECORD_ID>'); After…
Read More