Hi Friends ,
Here are the Winter 16 Release Notes for Developers . There are many but listed 5 useful updates for development.
1. getContent() and getContentAsPdf() call in Asyncronous methods
Now we can make calls to the getContent() and getContentAsPdf() methods of the PageReference class from within asynchronous Apex such as Batch Apex,
Schedulable and Queueable classes, and @future methods.
getContent() and getContentAsPdf() are now allowed after performing DML operations.
Calls to getContent() and getContentAsPdf() aren’t tracked against callout limits
Example :
PageReference pdf = Page.ExistingPage;
// add parent id to the parameters for standardcontroller
pdf.getParameters().put('id',accountId);
// the contents of the attachment from the pdf
Blob body;
try {
// returns the output of the page as a PDF
body = pdf.getContent();
// need to pass unit test -- current bug
} catch (VisualforceException e) {
body = Blob.valueOf('Some Text');
}
2. lock() and unlock() methods in Apex Approval Process:
Previously, we can set approval-process locks and unlocks only through the Salesforce user interface. Now salesforce enabled Lock () & UnLock() methods in Apex.
To enable this feature, from Setup, enter Process Automation Settings in the Quick Find box, then click Process Automation Settings.
Then, select Enable record locking and unlocking in Apex.
Salesforce admins can edit locked records. Depending on your approval process configuration settings, an assigned approver can also edit locked records.
Record locks and unlocks are treated as DML. They’re blocked before a callout, they count toward your DML limits, and if a failure occurs, they’re rolled back along with the rest of your transaction. To change this rollback behavior, use an allOrNone parameter.
Approval.LockResult and Approval.UnlockResult classes let you interact with the results of your programmatic record locks and unlocks.
// Query the accounts to lock
Account[] accts = [SELECT Id from Account WHERE Name LIKE 'Acme%'];
// Lock the accounts
Approval.LockResult[] lrList = Approval.lock(accts, false);
3 .Email Notifications for Unhandled Apex Exceptions
Configure email addresses that receive emails when your Apex code encounters unhandled exceptions.
Go to --> Setup, enter Apex Exception Email in the Quick Find box, then select Apex Exception Email.
You can also configure Apex exception emails using the Tooling API object ApexEmailNotification.
4. Reorder Your Batch Jobs Programmatically
System.FlexQueue class enable you to automate the prioritization of batch jobs in the Apex flex queue. Previously, you could reorder jobs in the flex queue only from the Salesforce user interface.
You can place up to 100 batch jobs in a holding status for future execution. When system resources become available, the jobs are taken from the top of the Apex flex queue and moved to the batch job queue. Up to five queued or active jobs can be processed simultaneously for each org. When a job is moved out of the flex queue for processing, its status changes from Holding to Queued. Queued jobs are executed when the system is ready to process new jobs.
EXAMPLE :
ID jobToMoveId = System.enqueueJob(new MyQueueableClass());
AsyncApexJob a = [SELECT Id FROM AsyncApexJob WHERE ApexClassId IN
(SELECT Id from ApexClass WHERE NamespacePrefix = null
AND Name = 'BatchJob')]);
ID jobInQueueId = a.ID;
Boolean isSuccess = FlexQueue.moveBeforeJob(jobToMoveId, jobInQueueId);
5.Unlimited Concurrent Callouts to Internal Salesforce URLs
Now we can make unlimited concurrent callouts to endpoints in your Salesforce org’s domain.
You no longer need to live in fear of hitting limits when you set up cross-org integrations to synchronize data between your orgs.
Previously, you could make only 20 simultaneous requests to URLs within one host, including to URLs within your org’s domain.
That limit has been lifted for internal URLs. However, you can still make only 100 total callouts in a transaction
including to internal URLs.
Thanks.