Mar 5, 2011

Error : "Trigger must be associated with a job detail"

Hi All,


While scheduling a class we some times gets error "Trigger must be associated with a job detail".


For example: I was facing this error when I schedule my class "ScheduleClass" using System.schedule, giving name to the schedule job "One Time ".


ScheduledClass SC = new ScheduledClass() ;
String sch = '0 0 10 * * ?';
System.schedule('One Time ', sch, SC);


Now please notice there is a space after "One Time ", when I removed this extra space from the name ("One Time") my class was scheduled as expected.


Thanks

Feb 26, 2011

Using Field Set on Visual Force Page

This is about how we can use Field Set. We can dynamically bind fields on our visual force page using Field Set. It is very useful when we are working with managed package.

A field set is a grouping of fields. For example we can have a field set that contains fields "Name , Email , Phone , Mobile". If the page is added to a managed package, administrator can add, remove, or reorder fields in a field set to modify the fields presented on visual force page without modifying any code. Creating a field set : Go to Setup > App Setup > Create > Objects > Select your object > Field Set (Beta) > New : 



Fields in "In the Field Set" section is displayed on visual force page and administrator can add more fields in "In the Field Set" from "Available for the Field Set" section.

Visual Force Page Code :



    
        
            
                
            
        
    



Now it will show three fields (Name, Email, Mobile) on visual force page, if we add "Phone" field from "Available for the Field Set" section to "In the Field Set" section then four fields (Name, Email, Mobile, Phone) will be displayed on visual force without changing the code.


Thanks

Jan 27, 2011

Spring 11 Release - Revised Governor Limits

Hi All,

Some interesting changes introduced in spring 11 release in Governor Limits are as follows :

1) The total number of DML statements issued for a process has gone from 20 for triggers, and 100 for everything else, to 150 for all contexts.

2) Total number of records retrieved by SOQL queries has gone from 10,000 to 50,000 .

Note : But standard set controller will accept 10,000 records only.

3) The limit on the number of items returned by the findSimilar method has been eliminated.

 Thanks

Jan 7, 2011

Inquery Behaviour With SOSL

Hi All,


Find something interesting and would like to share with you all.


I was firing SOSL query in my organisation to get an account (using it as keyword search) :


List<List<SObject>> lst = [Find 'test*' IN ALL FIELDS Returning Account] ;


There are more than 1000 records of account in my organisation, as SOSL query result limit I was returned with 200 records only. Record which I was expecting is not here in those 200 records. So I put a condition in INQUERY returning account :


List<List<SObject>> lst = [Find 'test*' IN ALL FIELDS Returning Account(id where id = '001A000000K1QS4')] ;


Now I was expecting the record to be returned as I put the Id in the INQUERY but still the record is not returned. Actual behaviour is first SOSL get its first 200 records then the INQUERY Id is searched from those 200 records.


Thanks

Dec 20, 2010

How Salesforce 18 Digit Id Is Calculated

Hi All,

As we know that each record Id represents a unique record within an organisation. There are two versions of every record Id in salesforce :

  • 15 digit case-sensitive version which is referenced in the UI
  • 18 digit case-insensitive version which is referenced through the API
The last 3 digits of the 18 digit ID are a checksum of the capitalizations of the first 15 characters, this ID length was created as a workaround to legacy systems which were not compatible with case-sensitive IDs.
The API will accept the 15 digit ID as input but will always return the 18 digit ID.

Now how we can calculate the 18 Digit Id from 15 Digit Id :

//Our 15 Digit Id
String id = '00570000001ZwTi' ;

string suffix = '';
integer flags;

for (integer i = 0; i < 3; i++) {
          flags = 0;
          for (integer j = 0; j < 5; j++) {
               string c = id.substring(i * 5 + j,i * 5 + j + 1);
               //Only add to flags if c is an uppercase letter:
               if (c.toUpperCase().equals(c) && c >= 'A' && c <= 'Z') {
                    flags = flags + (1 << j);
               }
          }
          if (flags <= 25) {
               suffix = suffix + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.substring(flags,flags+1);
          }else{
               suffix = suffix + '012345'.substring(flags-25,flags-24);
          }
     }

//18 Digit Id with checksum
System.debug(' ::::::: ' + id + suffix) ;


Thanks

Dec 6, 2010

Winter 11 Changes

Hi All,

Governor Limits

There are some good news with this winter 11 release, some governor limits are removed and some are increased like :

Removed Limits:

1) Total request time for one callout (HTTP request or web service call) has been removed.
2) Maximum size for a callout (HTTP request or Web service call) has been removed.

Increases to existing limits :

1) General heap size has been raised from 2 MB to 3 MB, with no scaling. In addition, batch Apex heap size is 6 MB.
2) Apex classes and triggers have been raised from 100,000 characters and 32,000 characters, respectively, and can now be one million characters long, not counting comments, test methode, and classes defined with @isTest.
3) Maximum ammount of Apex code allowed in an organisation has been raised from 1 MB to 2 MB.
4) Total number of ChildRelationship, RecordTypeInfo and PicklistEntry objects allowed and total number of fields calls allowed has been raised from 10 to 100.

Also in add on results of query in test class is increased from 500 to 10,000.

Visual Process Manager

Also with winter 11, you can now upload and manage business flows in salesforce.com. Visual process Manager, also known as Force.com Flow, and formerly known as Firefly, provides a robust business-friendly call scripting interface on the Force.com platform.

Apex Code Enhancements

1) isRunningTest method for system : Return true if the current executing code was called by code contained in a method defined as testMethod, false otherwise. Use this method if you need to run different code depending on whether it was being called from a test.

2) Void No Longer Accepted as Variable Type : Prior to winter 11, you could assign viod as a variable data type. While void is still an acceptable return type, you can no longer use it as a data type. For example, for all apex code saved using salesforce.com API version 20.0 or higher, the following is no longer valid :

Public class test
{
    Void v;
    Public void test(void arg1)
    {
    }
}


Custom Field Enhancements

Rich Text Area Field : There are two enhancements done in Rich Text Area in winter 11
1) Inline editing is now supported for richtext area field on detail page.
2) You can upload image to rich text area field from the salesforce.com API version 20 or later.

Thanks

Dec 4, 2010

Header Footer in PDF

Hi All,

It is about how we can put header and footer in a visual force page which is rendered as PDF.

<head>

<style>

@page {
    margin : 70pt .5in .5in .5in;
    @top-center {
        content : "My Header";
     }
    @bottom-left {
        content : "My Footer on Left Side";
        font-size : 10 px;
        color : #808080;
    }
    @bottom-center {
        content : "My Footer in center" ;
        font-size : 10 px;
        color : #808080;
    }
}

</style>

</head>

Now if we want to add a image in header then add:

@top-center {
        content : element(header);
     }

div.header {
    position : running(header) ;
}

in style and

<div class="header">
    <apex:image value="Image URL" />
</div>

before the body. We can also change font-size , font family , color etc of page using @page style.

Thanks