Thursday, 3 September 2015

Test classes with @isTest

Use the isTest annotation to define classes and methods that only contain code used for testing your application. The isTest annotation on methods is equivalent to the testMethod keyword.

  1. Classes and methods defined as isTest can be either private or public. Classes defined as isTest must be top-level classes.
  2. One advantage to creating a separate class for testing is that classes defined with isTest don't count against your organization limit of 3 MB for all Apex code.
  3. You can also add the @isTest annotation to individual methods
  4. Classes defined as isTest can't be interfaces or enums
  5. Methods of a test class can only be called from a running test, that is, a test method or code invoked by a test method, and can't be called by a non-test request.
  6. Test methods can’t be used to test Web service callouts. Instead, use mock callouts
  7. You can’t send email messages from a test method
  8. Methods of a public test class can only be called from a running test, that is, a test method or code invoked by a test method, and can't be called by a non-test request.

@isTest
                    
private class MyTestClass {
   @isTest static void test1() {
      // Implement test code
   }
   @isTest static void test2() {
      // Implement test code
   }
}

IsTest(SeeAllData=true) Annotation

use the isTest(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization,

  1. If a test class is defined with the isTest(SeeAllData=true) annotation, this annotation applies to all its test methods whether the test methods are defined with the @isTest annotation or the testmethod keyword
  2. The isTest(SeeAllData=true) annotation is used to open up data access when applied at the class or method leve

IsTest(OnInstall=true) Annotation

Use the IsTest(OnInstall=true) annotation to specify which Apex tests are executed during package installation. This annotation is used for tests in managed or unmanaged packages


Thursday, 6 August 2015

INVALID_FIELD_FOR_INSERT_UPDATE: Account: bad field names on insert/update


Insert error code INVALID_FIELD_FOR_INSERT_UPDATE: Account: bad field names on insert/update call: Salutation

This error often occurs when the default Account record type in Salesforce has been changed to a Person Account record type. The default Account Record Type must be set to a Business Account record type.

Resolution:


To resolved this, login to Salesforce and go to

Setup --> Manage Users --> profile --> and click on the Administrator profile ( or the profile of the Salesforce user specified in the Data Migration setup).


Scroll down to the Record Type settings and click on edit in the Accounts section. Modify the default record type to be a business account record type and click Save.


Wednesday, 5 August 2015

How to check which Salesforce edition we are using | Which salesforce edition



What edition of Salesforce do you have?

Solution :- We can check the same from below two option

1) Browser :- Click on Tab then you can see the detail like below screen shot




2) By Company Setup :- Best Option is to check the same from company profile.
Setup- > Company profile 
like below screen shot. 



Thanks,
Amit Chaudhary

Thursday, 30 July 2015

Custom Popup in Salesforce | Visualforce page



Please check below link for live demo
http://amitblog-developer-edition.ap1.force.com/CustomPopup




Class Should be:

public with sharing class CustomPopupController {

    public boolean showPopup {get;set;}
    
    public CustomPopupController ()
    {
        showPopup = false;
    }
    
    public PageReference openPopup()
    {
        showPopup = true;
        return null;
    }
    
    public PageReference Cancel()
    {
        showPopup = false;
        return null;
    }
    

}

Page Should be:-

<apex:page controller="CustomPopupController">
<style type="text/css">
    .popupBackground{
        background-color:black;
        opacity: 0.20;
        filter: alpha(opacity = 20);
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        z-index: 9998;
    }
    .custPopup{
        background-color: white;
        border-width: 2px;
        border-style: solid;
        z-index: 9999;
        left: 50%;
        padding:10px;
        position: absolute;
        width: 500px;
        margin-left: -250px;
        top:100px;
    }

</style>
<apex:form >
 <apex:pageBlock > 

 <apex:commandButton action="{!openPopup}" value="Open Popup" />
 
 <apex:outputPanel id="tstpopup" rendered="{!showPopup}">
                <apex:outputPanel styleClass="popupBackground" layout="block" />
                    <apex:outputPanel styleClass="custPopup" layout="block" >
                        <center>
                              Hello this is Custom pop-Up<BR></BR>
                             <apex:commandButton value="Save"  action="{!Cancel}" />
                             <apex:commandButton value="Cancel" action="{!Cancel}" />
                        </center>
                 </apex:outputPanel>
 </apex:outputPanel>

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

Please let us know if this will help you

Thanks
Amit Chaudhary

Saturday, 11 July 2015

Data Loading Tools


1) Jitterbit Data Loader for Salesforce   :- Fast, easy, no-coding integration for any SFDC Admin, Jitterbit Data Loader for Salesforce is a FREE data migration that enables Salesforce users to automate the import/export of data between flat files, databases, and Salesforce / force.com.

2) Dataloader.io   :Dataloader.io is simple, free, no download required app for Salesforce. 100% cloud solution to quickly import, export and delete data in Salesforce.com.

3) Informatica Cloud Data Loader :- Informatica Cloud Data Loader for Salesforce is a FREE data loading application that automates the import/export of Salesforce and Force.com data between databases and files.

3) WebSphere Cast Iron Data Loader  :- WebSphere Cast Iron Data Loader is a FREE cloud based integration solution that allows Salesforce users to import/exchange data between Salesforce and other data sources like flat files (csv), dropbox.com, and other Salesforce organizations in minutes

Wednesday, 1 July 2015

How to Refresh a record in Console



Include JS in VF page
<apex:includeScript value="/support/console/26.0/integration.js"/>

Then use below link to open new record .
<A HREF="#" onClick="RefreshPrimaryTab();return false">         Click here to refresh </A>

Write below Java Script code in VF page
    <script type="text/javascript">
    
        function RefreshPrimaryTab() 
        {
            sforce.console.getFocusedPrimaryTabId(showTabId);
        }
            
        var showTabId = function showTabId(result) 
        {
            var tabId = result.id;
            alert('Primary Tab IDs: primaryTabId ' + tabId );
            sforce.console.refreshPrimaryTabById(tabId , true, refreshSuccess);
        };
                   
        var refreshSuccess = function refreshSuccess(result) 
        {
            //Report whether refreshing the primary tab was successful
            if (result.success == true) 
            {
                alert('Primary tab refreshed successfully');
            } 
            else 
            {
                alert('Primary did not refresh');
            }
        };
       
    </script>

Imp Link :- http://www.salesforce.com/us/developer/docs/api_console/Content/sforce_api_console_methods_tabs.htm