ads

Thursday, 28 July 2016

How To Show Total No Of Reords in PageBlockTable





Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public class TotalContacts
{
 public String obj;
    public List<Contact> ContactList{get;set;}
    
    public TotalContacts() 
    {    
        ContactList= [SELECT ID, Name,lastname,email FROM Contact order by createddate limit 10];
    }   

}

Visualforce Page Code:-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<apex:page controller="TotalContacts">

<apex:pageblock Title="List of Contacts">
      
         <apex:pageBlock >
        <apex:pageblockTable value="{!ContactList}" var="u">
            <apex:column headerValue="Contact Name">
                <apex:outputLink value="/{!u.id}">{!u.Name}</apex:outputLink>
            </apex:column>
            
            <apex:column headerValue="Contact Email">
                <apex:outputLink value="/{!u.id}">{!u.Email}</apex:outputLink>
            </apex:column>
        </apex:pageblockTable>
    </apex:pageblock>  

    </apex:pageBlock> 

</apex:page>

OutPut Screen :-



Wednesday, 27 July 2016

Insert Record and Clear Fields value After Save




Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
public class outputPanelPage {
public contact con_insert{get;set;}

public string msg{get;set;}
public outputPanelPage()
{
 msg= 'Plz Enter the value...';
con_insert=new contact();


}

public void save()
{
  
   insert con_insert;
   con_insert=new contact();
   msg= 'Your Record is saved...';
}
}

VF Code :-


 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
<apex:page controller="outputPanelPage">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="SAVE" action="{!save}"/>

</apex:pageBlockButtons>

<apex:pageBlockSection columns="1">

<apex:inputField value="{!con_insert.lastname}"/>
<apex:inputField value="{!con_insert.AssistantName}"/>
<apex:inputField value="{!con_insert.Birthdate}"/>

</apex:pageBlockSection>


{!msg}


</apex:pageBlock>

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

Output Screen :-

             Screen 1 :- Before Save

           
         

              Screen 2 :- After Save











Use of ActionRegion,rerender,Param and Id






Controller Code :-


 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
public class ActionReson3{


public List<opportunity> opplist{get;set;}
public opportunity opp_var{get;set;}
Public id Recid{get;set;}

public boolean ShowHide {get;set;}
    
    public ActionReson3() 
    {    
    ShowHide=False;
        opplist = [SELECT ID, Name,closedate FROM opportunity limit 5] ;
    }   
     
     public void getRecordID()
     {
     showHide= True;
       opp_var= [select name, accountid,closedate,ForecastCategoryName,Amount,leadsource from opportunity where id=:Recid ];
    
       
     }

    
}


Visualforce Page :-



 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 controller="ActionReson3">
<apex:form >
<apex:pageblock Title="List of Opportunity">

<apex:pageblockTable value="{!opplist}" var="opp">
  <apex:column headerValue="Opportunity Name">
            
         <apex:actionregion >
        <apex:commandLink action="{!getRecordID}" value="{!opp.name}" rerender="pb" >
             <apex:param assignTo="{!Recid}" name="testuser" value="{!opp.id}"/>
             
         </apex:commandLink>
          </apex:actionregion>
          </apex:column>
         
           
            <apex:column headerValue="Close Date">
                <apex:outputLink value="/{!opp.id}" >{!opp.closedate}</apex:outputLink>
            </apex:column>
       
       
       
        </apex:pageblockTable>
        

    </apex:pageblock>
    
    
    <apex:pageBlock rendered="true" id="pb"  >
        <apex:pageBlockSection >
        <apex:outputField value="{!opp_var.name}"  />
        <apex:outputField value="{!opp_var.accountid}"/>
        <apex:outputField value="{!opp_var.closedate}"/>
        <apex:outputField value="{!opp_var.ForecastCategoryName}"/>
        <apex:outputField value="{!opp_var.Amount}"/>
        <apex:outputField value="{!opp_var.leadsource}"/>
        
</apex:pageBlockSection>
    
</apex:pageBlock>  


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



OutPut Screen :-

Use Of ActionRegion






Controller Code :-


 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
public class ActionRegionEXp
{
public String DepartmentStr{get;set;}
 public Contact conobj{get;set;}

 public ActionRegionEXp()
 {
  Conobj = new Contact();
 }
 public void FetchInfo()
 {
 
 
  if(DepartmentStr!=null && DepartmentStr!='')
  {
  
  
    List<Contact> ConLst = new List<Contact>();
    conLst = [select id,Department,title,email from Contact where Department=:DepartmentStr];
  
  
 
   if(conLst !=null && conLst.size()>0)
   {
     conobj= conLst[0];
     
     
    }
    else
    {
    Apexpages.Message message= new Apexpages.Message(ApexPages.Severity.Info,'No Record Found with this Department:' +DepartmentStr);
    ApexPages.addMessage (message);
    Conobj=Null;
    }
 
 }

}
}


Visualforce Page Code :-


 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
<apex:page controller="ActionRegionEXp">

<apex:pageMessages id="messgs"> </apex:pageMessages>
<apex:form >
<apex:pageBlock id="pageblock">

<table>
<apex:actionRegion >
<tr>
<td> <apex:outputLabel value="Enter Deparment">  </apex:outputLabel></td>

<td> <apex:inputText value="{!DepartmentStr}"/></td>
<td> <apex:commandbutton value="Get Info" action="{!Fetchinfo}" rerender="pageblock,messgs" /> </td>
</tr>

</apex:actionRegion>
<tr>
<td> <apex:outputLabel value="Contact Title"></apex:outputLabel> </td>
<td> <apex:inputField value="{!conobj.Title}"/> </td>
</tr>
 <tr>
     <td> <apex:outputLabel value="Contact Email"> </apex:outputLabel> </td>
      <td>  <apex:inputField value="{!conobj.Email}"/> </td>
     </tr>
</table>
</apex:pageBlock>

</apex:form>

</apex:page>


Output Screen :-



Update Existing Records Using List In Salesforce



Developer Console Code :-



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
      List<Account>  Acclist = [select id,website,name from Account];
      List<Account> Accupdate = new list<Account>();
        
        for(Account acc:Acclist){
            
            acc.website ='www.sfdcfor.com';
            acc.name = 'SFDC ForYou';
              
           Accupdate.add(acc);
         }
        
        update accupdate;


Result :-


Insert a New Record Using Developer Console




Account Record Insert :-



1
2
3
4
5
   Account acc = new Account();
           acc.name = 'india';
           acc.website = 'www.sfdcforyou.com';

    Insert acc;



Contact Record Insert :-



1
2
3
4
5
 Contact con = new contact();
         con.Lastname='Sfdcforyou';
         con.Department='Sfdcforyou';
        
 Insert con;


Schedule a Batch Class






Batch  Class :-



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
global class batchContactupdate implements Database.Batchable<sObject> {

global Database.QueryLocator start(Database.BatchableContext BC)
     {
    string Query='Select Name, Type from Contact';
     return Database.getQueryLocator(Query);
     }
       global void execute(Database.BatchableContext BC, List<Contact> scope)
       {
        for (Contact a : Scope)
        {
            a.Description='----This Description is updated by Batch Class------';
        }
       update Scope;
       
       }
     
      global void finish(Database.BatchableContext BC) 
    {
    }
 }

Scheduled Class :-



1
2
3
4
5
6
7
8
9
global class scheduledBatchable implements Schedulable {


   global void execute(SchedulableContext sc)
    {
      batchContactupdate b = new batchContactupdate(); 
      database.executebatch(b);
    }
}



Cron Expression :-


1
2
3
scheduledBatchable sc = new scheduledBatchable();
String sch = '0 5 * * * ?';
String jobID = system.schedule('Update Contact Job', sch, sc);


Scheduled Jobs :-




Apex Jobs :-







Batch Class In Salesforce






Batch Class Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
global class batchContactupdate implements Database.Batchable<sObject> {

global Database.QueryLocator start(Database.BatchableContext BC)
     {
    string Query='Select Name, Type from Contact';
     return Database.getQueryLocator(Query);
     }
       global void execute(Database.BatchableContext BC, List<contact> scope)
       {
        for (Contact a : Scope)
        {
            a.Description='----This Description is updated by Batch Class------';
        }
       update Scope;
       
       }
     
      global void finish(Database.BatchableContext BC) 
    {
    }
 }


Developer Console Code :-

1
2
batchContactupdate xyz = new batchContactupdate();
database.executebatch(xyz);



Apex Job :-




Tuesday, 26 July 2016

Method called from JS using Action function

In below example we are going to show you how you can call method from JS using ActionFunction

Flow Chart:-

1:- On click Radio button line 14 VF page ==> "javascript1()"

2:-Script call at line no 4 VF page ==> function javascript1()

3:- Function call at line no 5 VF page ==> ActionFunctionName();

4:- Now it goes to line no 10 ==>
      <apex:actionfunction name="ActionFunctionName" 
       action="{!ActionFunctionMeth}" rerender="ReftxtId"/>

5:-It will call action/Method  at line no 10 .{!ActionFunctionMeth}

6:- Now Method in Controller at line no 6 will update value in MyString variable .

7:- Updated value of MyString will shown to user using below code at line no 18 in VF page.

      <apex:outputText value="{!MyString}" id="ReftxtId"></apex:outputText>


 Controller Code:-

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Public class ExmplActionFunction {
Public string MyString{get;set;}

  public ExmplActionFunction (){}

  public string ActionFunctionMeth(){
     MyString = 'Method called from js using Action function After clicking on Radio Button';
     return null;
    }
}


Visualforce page :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<Apex:page controller="ExmplActionFunction">

<script> 
function javascript1(){
ActionFunctionName();
}
</script>
<apex:form >

<apex:actionfunction name="ActionFunctionName" action="{!ActionFunctionMeth}" rerender="ReftxtId"/>

<apex:pageblock >
<apex:outputLabel value="Click on Radio Button Below to call Contoller method from js using ActionFunction"></apex:outputLabel>
<apex:selectRadio onclick="javascript1()" ></apex:selectRadio><p/>
</apex:pageblock>

<apex:pageblock >
<apex:outputText value="{!MyString}" id="ReftxtId"></apex:outputText>
</apex:pageblock>

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


 User Interface :-




Thursday, 14 July 2016

Salesforce Certified Force.com ADM 201 - Spring '16 Release Exam

Que 1 :- What is true regarding the new Data Loader?

A. It has a new column flagging duplicate files.
B. It supports Web Server OAuth Authentication for Windows or Mac.
C. It has downloadable add-ons published through the AppExchange.
D. It works with all legacy security protocol.

Que 2 :-What key user access data is included in login forensics?


A. Who logged in from a new browser more than once in a day.
B. Who logged in more than the number set in the profile.
C. Who logged in during business hours.
D. Who logged in more than the average number of times.


Que 3 :- What does the Customize Application permission setting allow?


A. To create article types.
B. To edit contract settings.
C. To modify custom picklist values.
D. To create a new user.

Que 4 :- What object types is Work Orders object associated with?
Choose 2 answers

A. Products
B. Service Contracts
C. Milestones
D. Cases
E. Leads

Que 5. Which areas are calculated for the Health Check score?
Choose 2 answers

A. Number of users
B. Session Settings 
C. Profiles and Permissions assigned
D. Password Policy
E. Login attempts

Salesforce Certified Force.com Developer - Spring '16 Release Exam

Que 1:-What is true about Data Loader?
Choose three answers

A. It can be used with SAML Authentication.
B. It can be used with both Mac and PC.
C. It can be used with OAuth Authentication
D. It can be used with Password Authentication.
E. It can be used with only a PC.

 
Que 2 :-Which Quick Actions can contain a "Custom Success Message?"
Choose 2 answers

A. Send an Email

B. Update a Record
C. Visit a website
D. Log a Call

Que 3 :-What must be true when accessing a user's private reports and dashboards?
Choose 2 answers

A. Having the "Manage All Private Reports and Dashboards" permission.
B. Using the "allPrivate" with the "where" condition in a SOQL query.
C. Using the "allPrivate" with the "scope" condition in a SOQL query.
D. Having the "Administrator Access to Private Files" permission.

Que 4:-Which standard field can be updated using formula rules in process builder?

A. Deleted

B. ID
C. Created Date
D. Owner ID

Que 5 :-What is true about the file sharing "Set by Record?"

A. It is used to infer sharing via the record type.
B. It is used to infer sharing via the associated record.
C. It is used to infer sharing via the parent record.
D. It is used to infer sharing via the record owner.

Salesforce Certified Platform Developer I - Summer '16 Release Exam

*Post updated with Correct Answers...

Que 1 :-Which two objects can be queried with SOQL? (Select ONE)
 
A. DashboardSchedule
B. DashboardRefresh
C. DashboardComponent
D. LightningComponent



Que 2:- How can you make an External Object searchable via SOSL?
 
A. Request a custom index from Salesforce Support
B. Enable the "Allow Search" checkbox on the object
C. Use the Search.QueryExternal() method
D. Enable the "Is Searchable" checkbox on the object



Que 3:-  From where can you select and run Apex Test in the Lightning Experience?
  Choose 2 answers
 
A.   Apex Test Execution page in Setup
B. Testing API Page in Setup
C. Apex Test History page in Setup
D.   Test menu in the Developer Console
E. Apex Hammer Execution Status page in Setup



Que 4:- Which three Metadata components can be deployed via Change Sets?
  Choose 3 answers
 
A.   Lightning Application
B.   Wave Application
C.   Global Picklist
D.   Wave Dashboard
E.    Lightning Component


Que 5:- Which two features can be used to prevent values from being selected in a picklist?
  Choose 2 answers
 
A.  Validation Rules
B. Workflow Rules
C. Restricted Picklists
D.  Filtered Picklists
E. Validated Picklists

Salesforce Certified Force.com Developer - Summer '16 Release Exam

Que 1:-What are two features of Lightning Design Tokens?
  Choose 2 answers
 
A. Define essential values of visual design
B. Only one token file can be created per Org
C.  Reuse throughout Lightning component CSS resources
D. Cannot use Developer Console to Create Token Bundles



Que 2:-Which are the new Objects & their use case?
      Choose 3 answers
 
A.  LinkedArticle - Attach Knowledge articles to Work Orders
B.  AccountContactRelationship - link Contact to Multiple Accounts
C. EmailToObjectRelation - link email to multiple object records
D. EmailMessageRelation - link email message to multiple different types of objects
E. SharedContact - Share same contact record between multiple accounts


Que 3:- How can Messages to the end users be improved with the Toasts entity?                                    Choose 2  answers
 
A. When multiple messages are generated, they don't stack
B. Provide multiple actions for the user in one message
C. Use pre-configured toasts to customize the styling of your toast messages
D. Toast can be used in Visualforce to enhance user messages



Que 4:- What is true about Visualforce support in Lightning Experience?
 
A. Visualforce in Lightning owns the whole page
B. All features of Visualforce are available under Lightning Experience
C. Visualforce is supported in Lightning Experience
D. No changes are required to Visualforce to make it work under Lightning Experience



Que 5:- What are three ways a static resource can be referenced with the $Resource  Global Value Provider?Choose 3 answers
 
A.    Use in Lightning Component javascript controller
B.    Reference Images, Stylesheets & Javascript files
C.    In Visualforce markup but not in Lightning Component
D.    Use In Lightning Component markup
E. In Lightning Component markup but not in Javascript controller