Wednesday, September 10, 2014

39)How can we generate a pdf in visualforce page

<apex:page standardController="Account" extensions="AccountPdf"  showHeader="false"  sidebar="false" renderAs="PDF"  title="AccountReport.pdf"
         contentType="application/pdf#AccountReport.pdf" >
       
         <head>
             <title>AccountReport.pdf</title>
         </head>
         <apex:outputText value="Hello World"/>
 </apex:page>

38)How can you refresh a particular block in visualforce page ?

Using reRender attribute.

37)How much code coverage is needed for deployment?

Each trigger should have minimum of 1%. Class can have 0%. But, the total code covergae of 75%.

36)How can you call a controller method from javascript

Use action function component to call controller method from java script.

35)How can we implement pagination in Visualforce page ?

Use Standard sets controller for implementing pagination.

34)What is whoid and whatid in Salesforce ?

Whoid is the id of either contact or Lead. Whatid is the id of the related to record in activity record(standard or custom object)

33)What happens upon lead conversion ?

When lead is converted contact, account and optional opportunity is created.

32)What are the different ways of deployment in Salesforce

1) Change Sets
2 ) ANT
3) Eclipse

31)What are different portals in Salesforce.com?

Partner Portal:A partner portal allows partner users to log in to Salesforce.com through a separate website than non-partner users. Partner users can only view & edit data that has been made available to them. An organization can have multiple partner portals.
Customer Portal :Customer portal provides an online support channel for customers allowing them to resolve their inquiries without contacting a customer service representative. An organization can have multiple customer portals.

30)What is a Wrapper Class in Salesforce ?

A Wrapper class is a class whose instances are collections of other objects.

29)In How many way we can invoke the Apex class?

1) Visual force Page
2) Trigger
3) Web Services.
4) Email Services.

28)What is the difference between custom controller and extension?

Custom Controller: A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.
Controller extension: A controller extension is an Apex class that extends the functionality of a standard or custom controller.
“Although custom controllers and controller extension classes execute in system mode and thereby ignore user permissions and field-level security, you can choose whether they respect a user’s organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition.”

Friday, August 22, 2014

27) Field Accessibility in Salesforce

1. Go to Setup --> Administration Setup --> Security controls --> Field Accessibility.


2. Select the object.

3. Choose your view.

View by Fields

Use this option to choose a field and view a table of field accessibility for different profiles and record types.



4)View by Profiles
Use this option to choose a profile and view a table of field accessibility for different record types.



26)How to fetch data from Controller and display it in Visualforce page without using button?

To fetch data from Controller and display it in Visualforce page without using button, retrieve the record in the constructor.

Sample code:

Visualforce page:

<apex:page controller="Sample" >
    <apex:form >
       <apex:pageblock id="account" title="Account Details(Standard Object)" >
            <apex:pageblockTable value="{!acc}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.AccountNumber}"/>
            </apex:pageblockTable>
        </apex:pageblock>
       <apex:pageblock id="member" title="Member Details(Custom Object)">
            <apex:pageblockTable value="{!mem}" var="m">
                <apex:column value="{!m.Name}"/>
            </apex:pageblockTable>        
        </apex:pageblock>          
    </apex:form>
</apex:page>

Controller:

public with Sharing class Sample
{  
    public List<Account> acc {get;set;}
    public List<Member__c> mem {get;set;}  
     
    public sample()
    {
        acc = [SELECT Name, AccountNumber FROM Account];
        mem = [SELECT Name FROM Member__c];
    }
}


25) How to disable textbox in Visual force page based on Picklist values

Sample code:

Visualforce page:

<apex:page controller="Sample">
<apex:form >
<apex:actionFunction name="changeBoolCall" action="{!changeBool}"/>
    <apex:pageblock id="pg">
        <apex:pageblockSection >
            <apex:pageblockSectionItem >
                Select currency :
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
               <apex:selectList value="{!curency}" size="1" multiselect="false">
                   <apex:selectOption itemLabel="--- None ---" itemValue="none"/>
                   <apex:selectOption itemLabel="Indian Rupee" itemValue="inr"/>
                   <apex:actionSupport event="onchange" action="{!changeBool}" reRender="pg"/>
               </apex:selectList>
            </apex:pageblockSectionItem>          
            <apex:pageblockSectionItem >
                Enter the amount:
            </apex:pageblockSectionItem>    
            <apex:pageblockSectionItem >
               <apex:inputtext value="{!amount}" disabled="{!curencyBool}"/>
            </apex:pageblockSectionItem>                  
        </apex:pageblockSection>
    </apex:pageblock>
</apex:form>  
</apex:page>

Apex Controller:

public class Sample
{
    public String curency {get;set;}
    public String amount {get;set;}
    public Boolean curencyBool {get;set;}
   
    public sample()
    {      
        curency = 'none';
        if(curency == 'none')
        {
         curencyBool = true;
        }  
    }
   
    public void changeBool()
    {      
        if(curency != 'none')
        {
            curencyBool = false;
        }
        else
        {
            curencyBool = true;
        }
    }
     
}

24) Force.com Migration tool

The Force.com Migration Tool is a Java/Ant-based command-line utility for moving metadata between a local directory and a Salesforce organization.

The Force.com Migration Tool is especially useful in the following scenarios:
• Development projects where you need to populate a test environment with large amounts of setup changes
• Multistage release processes
• Repetitive deployment using the same parameters
• When migrating from stage to production is done by IT

Link for more information,

http://www.salesforce.com/us/developer/docs/daas/salesforce_migration_guide.pdf

Tuesday, August 19, 2014

23) How to check my Salesforce release

Since Salesforce.com is on cloud and sharing infrastructure with customers using Salesforce, users in the same instance will run the same version / release. See his blog for more information on sandbox - Salesforce Release and Sandbox

1) you can see the logo of the home page.


2) on the home page click on discover button and see the features of the release of that version.



22) How to Check your Salesforce instance

1) URL



  • In screenshot above this is ap1 instance.
  • while production instance for America instances start with NA, APAC instances start with AP, and EMEA instances start with EU
  •  Sandbox instance always start with CS
  • click here to see more instances
  • you want to know which instance your using simply click the link  in the link you have to mention the domain name and click on find button. 
2) SOQL : SELECT InstanceName, IsSandbox FROM Organization


21) How many salesforce editions are there

List of editions from (lower to higher)


  1. Contact Manager
  2. Group
  3. Professional
  4. Enterprise (included Developer edition)
  5. Unlimited 
  6. Performance
Remember you can upgrade from one edition to 'higher' edition using the same instance, but not to downgrade, for some reason when you opt-to downgrade, Salesforce will provide you new instance and you need to manually migrate all configuration and data, which is very troublesome

20) How to check my salesforce edition ?

There are few ways to do this

1. Setup-Administration setup



2. Hover your mouse over web browser
Once you have login to Salesforce, hover your mouse over the web browser tab.

In Google Chrome & Mozilla fire fox should be same.




Wednesday, August 13, 2014

19) Listbox using visualforce

<apex:page Controller="Listbox">
<apex:form >
<left>
<apex:pageBlock >
<b>Category:&nbsp;&nbsp;</b>
<apex:selectList value="{!ctgry}" size="1">
<apex:selectOptions value="{!ctgrys}"/>
</apex:selectList>  
</apex:pageBlock>
</left>
</apex:form> 
</apex:page>

public class Listbox
{

    public String[] ctgry = new String[]{};
 
    public Listbox()
    {

    }
 
    public List<SelectOption> getCtgrys()
    {  
      List<SelectOption> options = new List<SelectOption>();
      options.add(new SelectOption('India','India'));
      options.add(new SelectOption('CANADA','Canada'));
      options.add(new SelectOption('United States','US'));
      return options;
    }
 
    public String[] getCtgry()
    {
      return ctgry;
    }
 
    public void setCtgry(String[] ctgry)
    {
    this.ctgry = ctgry;
    }  

}


18) Disabling Sidebar using Visualforce

Hi All,
First the Visualforce page shows along with the sidebar
<apex:page>
</apex:page>


After then the sidebar will be disable by simply writing one line of code

<apex:page sidebar="false">
</apex:page>
By clicking save button it seems like that


17) SFDC login URL

Hi All,

Just you can login to salesforce by simply clicking the below URL

https://login.salesforce.com/

After clicking the URL the salesforce login page will appear in your browser with the user name and password.


16) What is SFDC

Hi All,
Salesforce.com is a CRM. It is based on cloud computing

  • There is no need of software and hardware to be installed
  • Just a browser enough (with Internet connection)
  • Log with username and password like gmail.
  • Everything is done effectively in the cloud. From any where you can login and logout.
  • Database is maintained by SFDC itself which is an added advantage for us.

15) Standard fields in Salesforce

1.Created By
2. Last Modified By
3. Owner
4. CreatedDate
5. ModifiedDate

Monday, August 11, 2014

14) How is a pdf generated using visual force page.

You can render any page as a PDF by adding the renderAs attribute to the <apex:page> component, and specifying “pdf” as the rendering service

<apex:page renderAs="pdf">
Visualforce pages rendered as PDFs will either display in the browser or download as a PDF file, depending on your browser settings

For more information Click here

13) How to display error messages in the Visualforce page?

To display error messages in the Visualforce page add below tag where you want to display the error message.

Visualforce page:
<apex:pageMessages />

Apex Controller:
 ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.');
ApexPages.addMessage(myMsg);

(OR)

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.'));

12) What is ApexPages.addMessage and what is package.xml?

Apexpages is  a class and Addmessge and Add messages are two method to show message from class to page.

ApexPages.addMessage: Add a message to the current page context. Use ApexPages to add and check for messages associated with the current page, as well as to reference the current page. In addition, ApexPages is used as a namespace for the Pagerefernce and Message classes.


The package.xml file, also known as the project manifest, is a control file that determines the set of metadata components
to retrieve or deploy in a project. In practice, it is much easier to use the Project Properties dialog to add or remove components
from a project—which modifies package.xml for you—but it is also possible to edit package.xml by hand.It holds complete schema of your org (like custom object, standard object, custom fields etc etc..). You can get more info in this PDF and also you can get some more information over this here

11) How can one read parameter values through the URL in Apex.

Hi,

If you have ID parameter in the  URL then try this apex code.

public Id oppid{get;set;}
Id id = apexpages.currentpage().getparameters().get('id');
 
If you want to read parameter in Visualforce the write in 
visualforce page :
<apex:inputField value="{!$CurrentPage.parameters.Paramtervalue}"/>

If you have to add a parameter to the URL the use
ApexPages.currentPage().getParameters().put(parameterName , value);

Wednesday, July 30, 2014

10) How to schedule Update reminders in Salesforce?

1. Go to My Settings.


2. Under Calendar & Reminders, select My Update Reminder.


















3. Select the required fields and click "Save" button.

















Sample email


9) Update Reminder in Salesforce

Updated and accurate opportunities drive precise forecasts. Ensure that your opportunities are up to date by enabling managers to schedule opportunity update reminders—automated opportunity reports that managers can customize for their teams.

1. Go to Setup --> Build --> Customize --> Opportunities --> Update Reminders.



2. Click "Edit" button. Enable Update Reminder. Click "Save" button.



3. Select the users. Click "Activate" button to activate the users to receive the updates.






Monday, June 9, 2014

8) How to set Proxy Settings in Ant deployment in Salesforce?

Code to be added in build.properties:


proxy.host = Proxy_Host
proxy.port = Port_Number
proxy.user = Username
proxy.pwd = Password

Code to be added in build.xml:

<target name="proxy">
 <property name="proxy.host" value="${proxy.host}" />
 <property name="proxy.port" value="${proxy.port}"/>
 <property name="proxy.user" value="${proxy.user}"/>
 <property name="proxy.pwd" value="${proxy.pwd}"/>
 <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}" proxyuser="${proxy.user}" proxypassword="${proxy.pwd}" />
</target>

7 ) Sales Cloud consultant exam just for 100$ and 100$ free coupon for future exams

Sales Cloud consultant exam just for 100$ and 100$ free coupon for future exams.


Check now in Web assessor now!

This is valid only up to June 27th, 2014.


6 ) Salesforce Sales Cloud Consultant Exam Syllabus

Industry Knowledge - 5%

Implementation Strategies - 7%

Sales Cloud Solution Design - 23%

Marketing and Leads - 7%

Account and Contact Management - 15%

Opportunity Management - 15%

Sales Productivity - 12%

Communities and Site Management - 5%

Sales Cloud Analytics - 5%

Integration and Data Management - 6%

Wednesday, June 4, 2014

5) SFDC Clone Custom Object

  • Create your new custom object with the name you want but don’t give it any fields yet.
  • Download the Force.com IDE (if you don’t already have it)
  • Connect it to your instance of Salesforce.com
  • Set the metadata settings when you connect it to download your custom objects.
Now you’ll find representations of both your source and destination custom objects in XML.  You can just copy most of the fields from the source object, paste them into the destination object, save, and voila — all the fields will be there.  You can add other fields this way manually if you want too, but I find it’s sometimes easier to add fields using the web UI.

4) Role VS Profile

Profiles control:

  • The objects the user can access/action
  • The fields of the object the user can access/action
  • The tabs the user can access/action
  • The page layout that is assigned to the user
  • The record types available to the user
  • Profile is required field on User.

Role control:

Record level access can be controlled by Role. Depending on your sharing settings, roles can control the level of visibility that users have into your organization’s data. Users at any given role level can view, edit, and report on all data owned by or shared with users below them in the hierarchy, unless your organization’s sharing model for an object specifies otherwise.










3) Remove the rights to delete Notes from an object related list

Can you remove the rights to delete Notes from an object related list?

Knowledge Article Number: 000079753

Description
We encounter a serious problem with the accountability of our approvals based on Attachments/Notes. These Notes should not be deleted from the records associated even if the User has edit abilities to the record. Is it possible to remove the right to delete an Attachment/Note to all Users or to a Profile? I do not see this option in the permissions.

Resolution
Because the permission to delete Notes and Attachments is tied to the Edit permission on the object of record itself, you will need to take the edit permission from the object as unfortunately it’s not possible to modify permissions to Notes & Attachments itself.

Please visit our Idea Exchange to promote the following Ideas:

Delete Notes
Disallow file deletion based on user profile permission

A workaround to this would be to create a Visualforce page that displays the Notes and Attachment related list, but without displaying the delete link to the Notes and Attachment records.

Another option would be to create a Trigger that would prevent the deletion of the Notes and Attachment records.


Probably the less costly solution to implement is to install the following package from the Appexchange:

2) Insert Records in SF by using JavaScript without Apex classes or controller.


Hi guys,

In this post i am showing how can we use the power of javascript in VF page and inserting record in salesforce without any standard/custom controller or Apex.

By using AJAX Toolkit we can do this task easily.

AJAX Toolkit divides in two type synchronous and asynchronous call.

It works in three simple steps:
Connecting to the AJAX Toolkit(By using login methods or getting Session_ID)
Embedding the API methods in JavaScript.
Processing the results.
in following example i am using synchronous call :-

<apex:page id="Page" sidebar="false">
    <script src="/soap/ajax/20.0/connection.js" type="text/javascript"></script>
    <script>
        function insertAccount(){
            // Getting Session ID.
            sforce.connection.sessionId = "{!$Api.Session_ID}";
         
            //Creating New Account Record.
            var account = new sforce.SObject("Account");
            //Getting Account Name from inputText.
            account.Name = document.getElementById("Page:Form:PB:PBS:PBSI:Name").value;
         
            // This is the line where magic happens, calling Create() method.
            var result = sforce.connection.create([account]);
         
            if (result[0].getBoolean("success")) {
                alert("New Account is created with id " + result[0].id);
            } else {
                alert("failed to create new Account " + result[0]);
            }
        }
    </script>
    <apex:form id="Form">
        <apex:pageBlock title="Insert Account" tabStyle="Account" id="PB">
            <apex:pageBlockSection title="Account Name" columns="1" id="PBS">
                <apex:pageBlockSectionItem id="PBSI">
                    <apex:outputLabel value="Name" />
                    <apex:inputText title="Name" id="Name" />
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
                <apex:commandButton onclick="return insertAccount();" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Screen Shots:



 After inserting of record you are having ID of record :


1) Adding Summary field as footer of pageblock table in vf page.

Hi All,

This post is simply showing how can we add the summary field or total amount or other information in footer of PageBlockTable or DataTable in vf page.

Here, in the following example I am showing sum of all the opportunity line items in footer of PageBlockTable,

i am using the <apex:facet name="footer"> tag to show the value in the footer.

Here the code:
<apex:page standardController="Opportunity">  
    <apex:pageBlock title="{!Opportunity.Name}">  
 
    <apex:pageblocktable value="{!Opportunity.OpportunityLineItems}" var="oli">
        <apex:column value="{!oli.PricebookEntry.Name}"/>
        <apex:column value="{!oli.Quantity}"/>
        <apex:column value="{!oli.UnitPrice}">
            <apex:facet name="footer">
                <apex:outputText value="Total:" style="float: right;"/>
            </apex:facet>
        </apex:column>
        <apex:column value="{!oli.TotalPrice}">
            <apex:facet name="footer">
                ${!Opportunity.Amount}
            </apex:facet>
        </apex:column>
    </apex:pageblocktable>

    </apex:pageBlock>
</apex:page>