Tuesday, July 11, 2017

Angular JS With Visualforce Page

In this post, I am going to share the information how you can use Angular JS with Visualforceto display records onto your Visualforce Page

ANGULAR JS

Angular is a Google-produced MVC framework where you can generate web applications and maintain them. This is Javascript based component framework which is open source. Here Visualforce and Salesforce1 can be used for making Salesforce compatible with mobile and also for connecting people to the Salesforce data. AngularJS allows the easy development of Visualforce pages.
This Approach have its on limitations and advantages
1. AngularJS allows us to extend HTML vocabulary for dynamic applications.
2. This allows developers to create reusable components with more efficiency.
3. In salesforce we can use both AngularJS to build single page application.
4. Angular is most used when you want to developed an UI or front
5. ng-app Declares the root element of an AngularJS application,
6. ng-bind Sets the text of a DOM element to the value of an expression.
7. ng-model Similar to ng-bind, but establishes a two-way data binding between the view and the scope.
8. ng-controller Specifies a JavaScript controller class that evaluates HTML expressions.
9. ng-repeat Instantiate an element once per item from a collection.
To learn Basics of Angular JS ,please go through the link provided http://webkul.com/blog/starting-with-angularjs.

ADVANTAGES AND LIMITATIONS

Advantage
1. Two way Data Binding.
2. It support SPA(Single Page Application).
3. MVC(Model View Controller) pattern supported.
4. Less code
Limitations
1.AngularJS Its have some limitation when we handling huge amount of data.

ANGULAR JS WITH VISUALFORCE PAGE

Apex ::
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public with sharing class AngularWithVfPage {
  
        /**
         * Webkul Software.
         *
         * @category  Webkul
         * @author    Webkul
         * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com)
         * @license   https://store.webkul.com/license.html
         */
 public static String getContacts() {
       return JSON.serialize([select id, name, email
           from contact ]);
   }
}
Visualforce::
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<apex:page showHeader="false" applyHtmlTag="false" docType="html-5.0" controller="AngularWithVfPage">
 <!--
        /**
         * Webkul Software.
         *
         * @category  Webkul
         * @author    Webkul
         * @copyright Copyright (c) 2010-2016 Webkul Software Private Limited (https://webkul.com)
         * @license   https://store.webkul.com/license.html
         */
         -->
<head>
   <meta charset="utf-8"/>
   <meta name="viewport" content="width=device-width, initial-scale=1"/>
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
   <script>
      
     var App = angular.module('myApp', []);
  
     App.controller('myctrl', function ($scope) {  
     
         $scope.contacts = {!contacts}
     });
   </script>
</head>
<body ng-app="myApp" class="container" ng-controller="myctrl">
   <table class="table table-bordered">
     <tr>
       <th>Name</th>
       <th>Email</th>
       <th>Id</th>
     </tr>
     <tr ng-repeat="contact in contacts | filter:query">         
       <td>{{contact.Name}}</td>
       <td>{{contact.Email}}</td>
       <td>{{contact.Id}}</td>
     </tr>
   </table>
</body>
</apex:page>

OUTPUT

 AngularJsWithVisualforce

SUPPORT


How to develop Salesforce Visualforce apps using AngularJS ?


If you need to display Salesforce data to people other than those that have Salesforce accounts, Visualforce pages is the best way to go. It allows users to view, edit, or even add data without exposing the data to third party systems. For developers creating Visualforce apps is way easier than creating ad-hoc third party web apps that call upon Salesforce data.
Seeing the popularity of Visualforce, Salesforce started expanding upon the product and within few years of its launch we saw support for jQuery, brand new REST API, and ForceTK; a JS proxy calling library. However, the game changer for Salesforce and JavaScript development was when Salesforce allowed JavaScript remoting for Apex Controllers. JS remoting allowed you to access server side apex controller methods through JS directly. Along with Remote Objects, this allowed more flexibility and dynamic usage of Visualforce pages resulting in an even greater adoption of the tool. More and more organizations were depending upon Visualforce pages to display data to clients, partners, and other users now. This called for a more appealing UI for the Visualforce pages and frontend JS framework and libraries were naturally called into the fray. AngularJS being the most popular one was naturally the favorite for the task of creating eye candy dynamic Visualforce pages.
In our previous post we talked about why exactly AngularJS is great for creating Visualforce pages. In this post, we will talk about the HOWS. I am assuming that you have some general understanding of AngularJS framework, Salesforce Visualforce pages, and have experience with JavaScript.
For more info on any topic check out these links, they may help.
AngularJS – https://docs.angularjs.org/tutorial
Visualforce – https://developer.salesforce.com/trailhead/module/visualforce_fundamentals

How to use AngularJS in Visualforce?

JavaScript saw a renewed interest partially because of the success of its frameworks and partially because of greater need for a more visually appealing mobile friendly single page application. In Visualforce pages, the backend part is not that flexible but that’s because of the level of security that comes with Visualforce. The frontend part, on the other hand, is all yours. So frontend frameworks like AngularJS are greatly preferred to create organized, structured applications having good response times.
Now considering that each Visualforce app involves around CRUD (create, read, update, delete) operations on Salesforce data, there are three prevalent approaches for fetching and binding data from Salesforce to Visualforce controllers.
Creating JavaScript Remote objects and using it with Visualforce,
Using JSON,
And using ForceTK libraries along with AngularJS libraries.
The differences are subtle in small apps but as the complexity of your app grows, the difference would be more prominent.
The beauty of Visualforce pages is that you can start coding from the word go without opening or uploading multiple files to a server or such. So here I am assuming that you have an understanding about VF pages and can create a standalone page in the SFDC setup.
In this example, we are going to fetch a list of ‘Contacts’ saved in Salesforce in a tabular form and even add a simple search function highlighting two-way data binding of AngularJS.
Let’s take a look at the main Visualforce page code :
<apex:page showHeader="false" Controller="ContactsController">
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
   </script>
   <link rel="stylesheet"  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
   
   <script type="text/javascript">
   var app = angular.module('MyApp',[]);  
   
   app.factory('VFRemotingFactory',function($q,$rootScope){  
       var factory = {};  
       factory.getData = function(searchText){  
           var deferred = $q.defer();  
           GetAllContactsByFilter(function(result){  
               $rootScope.$apply(function(){  
                   deferred.resolve(result);  
               });  
           }, searchText);  
           return deferred.promise;  
       }  
       return factory;  
   });
   
   function GetAllContactsByFilter(callback, searchText){  
       if(searchText == undefined)
       {
           searchText = '';
       }
       Visualforce.remoting.Manager.invokeAction(  
           '{!$RemoteAction.ContactsController.GetAllContactsByFilter}', searchText,
           callback,  
           {escape: false}  
       );
   }
   app.controller('myController',function($scope,VFRemotingFactory){  
       $scope.mcm = {};
       
       $scope.getFilteredData = function($event){
           if($scope.mcm.searchText.length > 1)
           {
               var searchTxt = $scope.mcm.searchText;
               VFRemotingFactory.getData(searchTxt).then(function(result){  
                   $scope.ContactData = result;  
               });
           }
           else
           {
               var searchTxt = $scope.mcm.searchText;
               VFRemotingFactory.getData().then(function(result){  
                   $scope.ContactData = result;  
               });
           }
           
       };
                $scope.Prafull = {};        
       VFRemotingFactory.getData().then(function(result){  
           $scope.ContactData = result;  
       });  
   });
   </script>
      
           <div ng-app="MyApp">
               <div ng-controller="myController">
                   <label>Search: <input ng-model="mcm.searchText" ng-keyup="getFilteredData($event)"/></label>
                   <table class="table">
                       <thead>
                           <tr>
                               <th>First Name</th>
                               <th>Last Name</th>
                               <th>Phone</th>
                               <th>Email</th>
                               <th>Title</th>
                               <th>Account Name</th>
                           </tr>
                       </thead>
                       <tbody>
                           <tr ng-repeat="contactVar in ContactData">
                               <td>{{contactVar.FirstName}}</td>
                               <td>{{contactVar.LastName}}</td>
                               <td>{{contactVar.Phone}}</td>
                               <td>{{contactVar.Email}}</td>
                               <td>{{contactVar.Title}}</td>
                               <td>{{contactVar.Account.Name}}</td>
                           </tr>
                       </tbody>
                   </table>
               </div>
           </div>
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</apex:page>
Now let’s analyse this code. We started off by including a custom Salesforce apex
controller<https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm> for pulling contacts that we named very ingeniously “ContactsController”. This custom controller is also very simple.
public class ContactsController {
   @RemoteAction
   public static List<Contact> GetAllContactsByFilter(String searchText)
   {
       String searchString = '%' + searchText + '%';
       List<Contact> contactList = [SELECT FirstName, LastName, Phone, Email, Title, Account.Name FROM Contact where FirstName like :searchString];
       return contactList;
   }
}
As you may have guessed we are using JS Remoting to access to pass on our data.
We start off by creating our first AngularJS module that answers to name ‘MyApp’, var app = angular.module(‘MyApp’,[]). This app is referenced in the main body div through
<div ng-app="MyApp">
In our main body, we have created an input box that defines what we are going to display. By default, the content is ‘’ i.e. blank which triggers the app to display all contacts. As we start typing in the search box, it starts to filter out data based on the value in search box, in real-time, in the same page, without refreshing. This is the magic of two-way data binding.
Now from here on now we started to complicate things a little. The main angular controller that we again ingeniously named “myController” is the brains behind the module’s (or app) operations and we have included it in our nested div of the body.
We then created a module factory that invokes “GetAllContactsByFilter” function which in turn invokes Visualforceremote objects and our custom Visualforce controller ContactsController. This factory returns the list of contacts based on the search text, which by default is blank.
We created a scope object named ‘mcm’ that contains the model data that we input through Search input field. The $scope is the main magician that binds view with model.
The ng function ng-keyup=”getFilteredData($event) that we referenced in search input, triggers a new event whenever a key is entered in the search box. Triggering of this event results in automatic changing of model and in our example, automatic changing of view as well. You can restrict changing of view through a button.
Our AngularJS controller ‘myController’, triggers fetching of data based on the input value. For blanks it fetches all data so does it for typing only single alphabet. When the input string’s length becomes greater than one it filters out the data based on input string. The fetched data is stored in scope object ‘$scope.ContactData’ which in turn passes on data to ‘contactVar’ that finally displays data.
To summarize how AngularJS helped most in this really small and basic example:
  • The ng-keyup automatically trigger events based on user input. A custom function for this is tricky at best.
  • The two way data binding using custom code is full day work at best. We did it in 1 hour.
  • ng-repeat, the small function used to populate the table, a custom code for it will take at least 3-4 hours. We did in blink.
  • To add automatic filters we just have to add a line in the ng-repeat reference. For example, if we have to filter by an account we just have to add ng-repeat=”contactVar in ContactData | filter:account”. (Assuming account is the predefined variable).

An Even Simpler Approach

Now in the previous example, we have needlessly complicated things through module factory and Visualforceremoting. This use case can be achieved through a simpler code. Checkout the following code:
<apex:page standardStylesheets="false" sidebar="false"
   showHeader="false" applyBodyTag="false" applyHtmlTag="false"
   docType="html-5.0" controller="AngularDemoController">
<html lang="en" ng-app="demoApp">
<head>
   <meta charset="utf-8"/>
   <meta name="viewport" content="width=device-width, initial-scale=1"/>
   <title>Angular Demo</title>
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
   <script>
     // define the app
     var demoApp = angular.module('demoApp', []);
     // add the controller
     demoApp.controller('DemoCtrl', function ($scope) {
         $scope.account = {!account}
         $scope.contacts = {!contacts}
     });
   </script>
</head>
<body class="container" ng-controller="DemoCtrl">
   <h1 style="color:Green">{{account.Name}}</h1>
   <p class="lead" style="color:Gray">
   {{account.BillingStreet}}<br/>
   {{account.BillingCity}}, {{account.BillingState}}
   {{account.BillingPostalCode}}
   </p>
    <b>Search</b>&nbsp;&nbsp;&nbsp;<input ng-model="query" /><br/><br/>
    
    
   <table class="table table-bordered">
     <tr>
       <th>Name</th>
       <th>Email</th>
       <th>Id</th>
     </tr>
     <tr ng-repeat="contact in contacts | filter:query">          
       <td>{{contact.Name}}</td>
       <td>{{contact.Email}}</td>
       <td>{{contact.Id}}</td>
     </tr>
   </table>
</body>
</html>
</apex:page>
Here is the code for controller:
global with sharing class AngularDemoController {
   // hardcode an account id for demo purposes
   static String accountId = '00128000003u3uK';
 
   global static String getAccount() {
       return JSON.serialize([select name, billingstreet,
           billingcity, billingstate, billingpostalcode
           from account where id = :accountId][0]);
   }    
 
   global static String getContacts() {
       return JSON.serialize([select id, name, email
           from contact where accountId = :accountId]);
   }
}
Here we are using the JSON approach, and using Salesforce’s inbuilt features like ‘!account’ and ‘!contact’ that automatically lookout for getAccount variable and method called in a custom controller. In this example, we have created an app to fetch contacts of an account whose ID we have hardcoded (I was a little lazy there).

Monday, July 10, 2017

List of Annotations in Salesforce Apex

Usually Annotation means which will specifies the behavior or modifies the way how the particular class or method behaves in salesforce. Based on annotations the functionality or behavior and usage of particular class or method we can simply identify.

  • Each annotation will starts with '@' symbol and followed by name of the annotation
  • To declare a method/class with annotations it must be declared immediately before method/class  
Method with Annotation Example

public class UserHistoryProcessor
{
   @InvocableMethod 
  public static void updateUserHistory(List<Id> userIds)
  {
    //related code here
  }
 
}

List of Available Annotations in Apex
  • @isTest
  • @InvocableMethod
  • @InvocableVariable
  • @future
  • @AuraEnabled
  • @ReadOnly
  • @RemoteAction
  • @TestSetup
  • @TestVisible
  • @Deprecated
Apex REST annotations:
  • @RestResource(urlMapping='/yourUrl')
  • @HttpDelete
  • @HttpGet
  • @HttpPatch
  • @HttpPost
  • @HttpPut
we will discuss about each and every annotations with examples in next post please keep following the blog for latest updates

System.QueryException: List has no rows for assignment to SObject

Usually we will come across this type issue in many places and in many situations also .In the same way I have come across the same issue in one of the my class and I have done some work around it to fix this issue.I will explain this one with an example which may brings you an complete understanding about the issue.

Scenario:
I have 3 objects called Time_Track__c,Expert__c and User.Expert__c and User having a lookup relationship where User (Sforce_User__c) is acting as parent for Expert object and Time_Track__c and Expert__c also having lookup relationship where Time_Track__c is acting as child for Expert (Expert_Name__c) object .I have an visual force page which is using Time_Track__c  as a Standard Controller and I am having some extension class on same page .In the constructor of the extension class I am trying to query on Expert__c object based on logged in user to assign this expert to new time track as shown below

Source Code:
public class TrackExtn {
  public Time_Track__c timeTrack{get;set;} 

  public TrackExtn(ApexPages.StandardController controller) {
    timeTrack = new Time_Track__c();        
    timeTrack= (Time_Track__c)controller.getRecord();
       
    if(controller.getId()==null)
    {
       Expert__c exp = new Expert__c();
       //In below line you will receive List has no rows for assignment to SObject
       exp = [Select id from Expert__c where Sforce_User__c=:UserInfo.getUserId() limit 1];
       timeTrack.Expert_Name__c = exp!=null?exp.id:null;
           
    }

    }
}

Error:

When you execute the above code at run time if your having at least one matching Expert__c record for logged in user it will work very smoothly .If there is no matching Expert__c record for logged in user will end up with System.QueryException: List has no rows for assignment to SObject . Even if the matching record is not there it should continue fir the next lines with out throwing any error but here it's failing and terminating the complete execution. To handle this we need to follow below work around solution.


Workaround Solution:

We need to convert the Query result holder from SObject type to List<SObject> type that will resolve the issue .Please look at the below code for the work around solution
public class TrackExtn {
  public Time_Track__c timeTrack{get;set;} 

  public TrackExtn(ApexPages.StandardController controller) {
    timeTrack = new Time_Track__c();        
    timeTrack= (Time_Track__c)controller.getRecord();
      
    if(controller.getId()==null)
    {
        //Convert Sobject type to List<Sobject> type to store query result
        List<Expert__c> listexp =new List<Expert__c>();
        listexp = [Select id from Expert__c where Sforce_User__c =:UserInfo.getUserId() limit 1];
        System.debug('loggedinTech ..'+listexp );
        td.Technician__c = listexp.isEmpty()?null:listexp[0].id;
           
    }

    }
}

How to set Createddate Field value for Test Record in Salesforce Test class

(Note: The feature we are discussing here is as per the Salesforce Spring 16 preview release notes,So this feature is available from Spring 16 release of Salesforce, but features may or may not be available after the Spring 16 go to live )

Before Spring 16 if you are inserting let assume 20 test records in salesforce test class for all those 20 test records the created date is same .If you are working any scenario like to fetch only latest records 20 you will be getting all that 20 records with same created date because all records are inserted with same date so you can't guaranty that in which order they are coming even if you are using order by created date.

From Spring 16 release releasing this great feature to set the created date by the developer for the test records in salesforce test classes (It may or may not be released in Spring as per the note above).

The new Test class method called Test.setCreatedDate(RecordId,DateTime) which allows to set the created date for the test records in salesforce test class.

How to use:
1 . Create a test record in test class.
2.  Pass that record Id along with date time that you want set to Test.setCreatedDate(Id,DateTime).
 @isTest   
 private class SetCreatedDateTest {  
   static testMethod void testSetCreatedDate() {  
     Account a = new Account(name='Test Account');  
     insert a;  
     Test.setCreatedDate(a.Id, DateTime.newInstance(2012,12,12));  
     Test.startTest();  
     Account myAccount = [SELECT Id, Name, CreatedDate FROM Account   
                WHERE Name ='Test Account' limit 1];  
     System.assertEquals(myAccount.CreatedDate, DateTime.newInstance(2012,12,12));  
     Test.stopTest();  
   }  
 }  

Key points:
1.All database changes are rolled back at the end of a test. You can’t use this method on records that existed before your test executed.
2.You also can’t use setCreatedDate in methods annotated with @isTest(SeeAllData=true), because those methods have access to all data in your org.
3.This method takes two parameters—an sObject ID and a Datetime value—neither of which can be null.
4. You can see the doc related to this setCreatedDate at Reference Doc for SetCreatedDate.

I think now everyone is eagerly waiting for this new feature.Enjoy....!


How to Delete the Records Permanently from the Recycle Bin in Salesforce


Basically in salesforce when you have deleted any record from an object, it will not be deleted permanently and it will be stored in Recycle bin till 15 days from the deletion date.The number of records stored in recycle bin depends on Number of Licenses your organisation has pursed and multiply it with 5000 records.
If the number of records in recycle bin crosses this limit salesforce automatically deletes the old records from Recycle Bin which are at least in recycle bin for 2 hours.If you want to delete the records permanently from recycle bin before salesforce deletes it you can emptyRecylebin() method.


     EmptyRecycleBinResult[] = DataBase.emptyRecyclebin(List of Ids)

Example:

    1. Account Acc = new Account(Id='0016000000I549m');
        Database.emptyRecycleBin(Acc);


Notes:

1. Maximum number of records per call that we can pass is 200
2. Using this function records deleted can not be undeleted again.
3. Theses deleted records from recycle bin can be accessed using the DataBase.queryAll() for some time typically that would be with in 24 hours or may shorter or longer.

Friday, July 7, 2017

Inner Popup using Salesforce

Visualforce page:

<apex:page controller="showAll" >
<apex:form >
<!--    CSS Style    -->
<style type = "text/css">

.headr
{
font-size:17px;
font-weight:bold;
color:maroon;
}

.popup
{
background-color: white;
border-width: 2px;
border-style: solid;
z-index: 9999;
left: 50%;
padding:10px;
position: absolute;
width: 500px;
height:60%;
margin-left: -250px;
top: 25px;
overflow:scroll;
}
     
.popupBg
{
background-color:black;
opacity: 0.20;
filter: alpha(opacity = 70);
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 9998;
}

</style>
<!--    End of CSS Style    -->

<apex:pageblock >
<table cellspacing = "7" cellpadding = "7">
<tr>
<td><apex:commandLink styleClass="headr" action="{!members}" reRender="members">Members</apex:commandLink></td>
</tr>
<tr>
<td><apex:commandLink styleClass="headr" action="{!blogs}" reRender="blogs">Blogs</apex:commandLink></td>
</tr>
<tr>
<td><apex:commandLink styleClass="headr" action="{!photos}" reRender="photos">Photos</apex:commandLink></td>
</tr>
</table>
</apex:pageblock>
<apex:outputPanel id="members">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
        <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
        <apex:pageblock title="Members" >
         <apex:pageBlockTable value="{!memb}" var="mem">
         <apex:column value="{!mem.Name}"/>
         <apex:column value="{!mem.E_Mail_Id__c}"/>
         <apex:column value="{!mem.Mobile_Number__c}"/>
         </apex:pageBlockTable>
         <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="Ok" action="{!closePopup}"/>
         </apex:pageBlockButtons>
         </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

<apex:outputPanel id="blogs">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
        <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
        <apex:pageblock title="Blogs" >
         <apex:pageBlockTable value="{!blog}" var="blg">
         <apex:column value="{!blg.Name}"/>
         <apex:column value="{!blg.URL__c}"/>
         </apex:pageBlockTable>
         <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="Ok" action="{!closePopup}"/>
         </apex:pageBlockButtons>
         </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

<apex:outputPanel id="photos">
<apex:outputPanel styleClass="popupBg" layout="block" rendered="{!displayPopUp}">
        <apex:outputPanel styleClass="popup" layout="block" rendered="{!displayPopUp}">
        <apex:pageblock title="Photos" >
         <apex:pageBlockTable value="{!photo}" var="pht">
         <apex:column value="{!pht.Name}"/>
         <apex:column value="{!pht.ID}"/>
         </apex:pageBlockTable>
         <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="Ok" action="{!closePopup}"/>
         </apex:pageBlockButtons>
         </apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
</apex:outputPanel>

</apex:form>
</apex:page>

Apex:

public class showAll
{
    public boolean displayPopup {get; set;}
    public List<Member__c> memb {get;set;}
    public List<Blog__c> blog {get;set;}
    public List<Photo__c> photo {get;set;}
  
    public showAll()
    {
     displayPopup = false;
    }
  
    public void members()
    {
     displayPopup = true;
     String sql = 'SELECT Name,E_Mail_Id__c,Mobile_Number__c FROM Member__c';
     memb = Database.Query(sql);
    }
  
    public void blogs()
    {
     displayPopup = true;
     String sql = 'SELECT Name,URL__c FROM Blog__c';
     blog = Database.Query(sql);
    }   
  
    public void photos()
    {
     displayPopup = true;
     String sql = 'SELECT Name,ID FROM Photo__c';
     photo = Database.Query(sql);
    }
  
    public void closePopup()
    {
     displayPopup = false;    
    }
}

Output: