Thursday 20 September 2012

Unsupported parameter type in @future Method Using Trigger

Hi, Guys you can't pass Sobjects as parameters into asynchronous methods. "Methods with the future annotation cannot take sObjects or objects as arguments." You can pass a list or set of ID's and then query for the objects inside the method.

Trigger

trigger test on Book__c (before Update) {
    if(Trigger.isUpdate){
        LIST<String> myOldObjectststId = new LIST<String>();
        LIST<String> myNewObjectststId = new LIST<String>();
        
        Set<String> opportunitysalesids = new Set<String> ();        

        for (Book__c  b1 : [Select Id from Book__c where id in :Trigger.old]) { 
           myOldObjectststId.add(b1.id);         
        }
        for (Book__c  b2 : [Select Id from Book__c where id in :Trigger.new]) { 
           myNewObjectststId.add(b2.id);         
        }
        MyObjectUpdateAfter.testMethodFuture(myOldObjectststId ,myNewObjectststId );
    }
}


Class with Future Method

public class MyObjectUpdateAfter{
    @future
    public static void testMethodFuture(LIST<String> myOldObjectstst,LIST<String> myNewObjectstst){
        //Now use these Id of  myOldObjectstst & myNewObjectstst

    }
}

Winter '13 Force.com Platform Release Geolocation Custom Fields

The geolocation custom field allows you to create a field that identifies a location by its latitude and longitude. You can then use the geolocation field with the DISTANCE and GEOLOCATION formula functions to calculate distances between locations. For example, you can calculate the distance between two geolocation fields (such as between the warehouse and the store), or between a geolocation field and any fixed latitude-longitude coordinates (such as between the warehouse and 37.775°, –122.418°, also known as San Francisco).
Geolocation Field Limitations Geolocation is a compound field that counts toward your organization’s limits as three custom fields: one for latitude, one for longitude, and one for internal use. In this beta release, support for the compound field (geolocation) vs. the field’s components (latitude and longitude) varies depending on the functionality you’re using in Salesforce. For example, you can create list views that show the field and its components, but you can’t select the compound geolocation field in Apex; you can only run SOQL queries on a geolocation field’s components.

Other limitations of this geolocation beta release include:

1. History tracking is not available for geolocation fields.
2. Geolocation fields are not supported in custom settings.
3. Geolocation fields are not available in reports, dashboards, validation rules, Visual Workflow, or workflow and approvals.
5. Geolocation fields cannot be searched.
6. Geolocation fields are not available in Schema Builder.
7. DISTANCE and GEOLOCATION formula functions are available only when creating formula fields and in Visual Workflow.
8. Geolocation is supported in Apex only through SOQL queries, and only at the component level.


New in Winter '13 Release

Winter '13 Release on September 12, 2012


New in Winter '13 Release

1. Developer Console Enhancements: The Developer Console makes developing with Apex code even easier by adding tools for unit testing, querying and performing DML operations on your data. We'll also cover the new command line window and the flexibility to tailor the console layout.

2. Visualforce Enhancements: Visualforce charting is now generally available. In addition to being available to all Visualforce customers, charting features such as new chart types, control over color schemes, and enhanced rendering control.

3. Apex Code Enhancements: New interfaces to support testing callouts for both HTTP requests and for WSDL generated code, new string methods, additional JSON support, and non-primitive types in Map and Set keys.

4. The new Force.com Canvas: In pilot for Winter '13, the canvas framework allows for integration of third party applications within Force.com. Made up of a set of Javascript APIs, the Force.com Canvas allows for embedding of an app inside the Force.com UI and provides support for authentication between apps, cross-domain XHR, and the context about the environment in which the app is running.


Wednesday 19 September 2012

Throw the Exception in the Class

An exception is a special condition that changes the normal flow of program execution. That is, it's when something bad happens that the program can't deal with during execution. Exceptions are the language's way of throwing up its hands and saying, "I can't deal with this, you need to."
So what kinds of conditions can cause Apex to raise, or throw, an exception? Here are the most common examples:
1. Your code expects a value from something that is currently null
2. An insert or update statement fails to pass a custom validation rule you have set
3. Assigning a query that returns no records or more than one record to a singleton sObject variable
4. Accessing a list index that is out of bounds

In all these instances we're trying something that the language deems impossible, and an exception is thrown. Apex has 20 different kinds of exceptions--that's a lot of different kinds of exceptions, but since they're all subclassed from a generic exception class they are very similar to deal with. All the exceptions support standard methods for accessing the error message and the exception type.


Throw the Exception in the Class



public class ExceptionHandlingClass{}

try {
    // Your code here 
    
   throw new BaseException('This is Exception Handling');
} catch (Exception e) {  
    // This catches the Exception 
    
}
public class BaseException extends Exception {}

}

Friday 14 September 2012

Developer Console - Search text in Class Options

There are near X (cross for close ) , "Open in new window" component like this Sign (▲) click this & Simply Clicking (Ctrl +F) you can search anything in Class at Developer Console... There are given SnapShot :--


Thursday 13 September 2012

Difference b/w apex:actionFunction tag and JavaScript remoting

The apex:actionFunction tag:-
1. lets you specify rerender targets
2. submits the form
3. does not require you to write any JavaScript


JavaScript remoting:
1. lets you pass parameters
2. provides a callback
3. requires you to write some JavaScript