Posted in Code Snippets, Salesforce

Salesforce Lightning : Show or Hide a Modal

Modal popup can be added using SLDS as shown here.
It can be shown or hidden in two ways:

  1. Using CSS Class
  2. Using attribute variable

Continue reading “Salesforce Lightning : Show or Hide a Modal”

Advertisements
Posted in Code Snippets, Salesforce

Salesforce: Making a Trigger to execute at last

I had an After trigger in a Grand-child object that does some calculations with Child object and updates the result in Parent object. All the calculation logic were perfectly alright. But the result was wrong!

Continue reading “Salesforce: Making a Trigger to execute at last”

Posted in SQL

Chained data using single SQL Query (Fixed Length)

In e-commerce sites and in other applications, database sometimes will be designed in such a way that single table has child records in a chained fashion. Like, while defining a Product Type, Category and Sub-Category. A Sub-Category points to a Category in a same table and Category points to a Product Type in a same table. This Chained table has a format of Grand Parent, Parent and Child in same table as:

id parent_id name
1 0 John
2 1 Jacob
3 2 James
4 0 Jessie
5 4 Jemimah
6 5 Julia

Continue reading “Chained data using single SQL Query (Fixed Length)”

Posted in Code Snippets, Javascript

Workaround for failed loading of images

Images that depend on server-side loading fails sometimes due to multiple reasons, like image is not present, location might be wrong, browser fails to load or process the image. All these returns 404 as HTTP status. This breaks the image placeholder too. Using JQuery, the broken image can be replaced with the error placeholder image with this simple JQuery snippet:

Continue reading “Workaround for failed loading of images”

Posted in Code Snippets, PHP

PHP: Implode or Trim – Concatenating strings in a loop

There are bunch of questions circulating in Stack Overflow like this. People when trying to concatenate some strings with another string or a character, they simply concatenate with . inside the loop like this:

$values = [1, 2, 3];
$string = '';
foreach ($values as $value) {
   $string .= $value . " AND ";
}
echo $string;

This leaves string like this:

1 AND 2 AND 3 AND

Then they come up with a question as how to remove the last AND.

Continue reading “PHP: Implode or Trim – Concatenating strings in a loop”

Posted in Angular, Code Snippets

Make bootstrap button group to work with Angular

Many developers face the trouble to make the Twitter Bootstrap’s button group, toggle buttons to work with Angular. For instance, following is the code for button group – btn-group

<div class="btn-group">
    
         Radio 1
    
    
         Radio 2
    
    
         Radio 3
    
</div>

But ng-model doesn’t seem to work with this.

Continue reading “Make bootstrap button group to work with Angular”