Wednesday, 28 October 2015

Playing with Record Types - APEX

HI Friends ,

In this I am going to demonstrating the sample mechanism to get record types for the particular object in to apex.

1. Using describe object , we can get Record Types Names and Record Type Ids .Below is the example,

String StrRecordTypeId =  Schema.SObjectType.Account.getRecordTypeInfosByName().get('Business').getRecordTypeId();

The above code returns the record type id of the Business record type.

2. Another way to get Record type is query on the Record Type object .

           Select Id From RecordType where sobjecttype = 'Opportunity'

The above query gives us all record types defined on the opportunity object.


Hope above 2 are use full.

Thank you.

Tuesday, 13 October 2015

Salesforce Winter 16 Release Notes

Winter ’16 is here! After a nice Dreamforce shaped break we can all get stuck into a whole host of new features Salesforce has kindly laid out for us. Winter ’16 is clearly one of the biggest releases that most of us can remember with the announcement of the Lightning Experience. Putting LE to one side for a minute though, this release is full of a whole host of other features that are going to make our lives as users/admins/consultants that little bit easier. Let’s dive into a short breakdown of some of the more notable features.
  • No longer accessible from Setup or the Accounts, Contacts, Leads, Campaign Detail, and My Settings pages.
  • Legacy Import “My Accounts and Contacts” is being retired
  • Why? The Data Import Wizard is more capable.
  • Consists of three things:
    • Lightning Experience Desktop App: 25 new features, modern UI, faster
    • Lightning App Builder: Drag & drop to make customizations quick and easy
    • Lightning Design System: Style guide, design patterns, and component library.
  • Sales analytics are better and easier to configure.
  • Create tasks, update a record, and share insights
  • Ability to route incoming work items (Cases, chats, calls, leads, etc..) to specific users.
  • Helps to eliminate queue cherry picking or the wrong people working your service calls/cases.
  • Also helps load balance the incoming work
  • New Sales & Service Events added
  • Will listen for when specified records are created or updated to trigger customers into a specific journey, which is enhanced by personalized communications.
  • Communities is now known as Community Cloud.
  • Lighting components now available in Community Builder
  • Create and customize custom objects in a new streamlined setup
  • Create pages by dragging and dropping components
  • Related: The new Object Manager can be used to manage both standard and custom objects in one place.
  • Rollup Summary Field limit increased from 10 to 25
  • Multi-Select picklists can now have 500 values! (Don’t tell your users)
  • “Restricted Picklists” This feature can prevent users from making up their own picklist values when loading data.
  • Previewing files is fast and looks great.
  • New: “Broadcast Groups” – type of group where only owners and managers can create new posts
  • Ability to mute posts
  • Write Chatter posts in rich text
  • Connect for Outlook is now retired
  • Duplicate rules now run as users complete fields on a record, not just when they hit “Save.”
  • Enabled Lookup Relationship field for activities, but there is still a list of
  • New: “Salesforce Console for Service” – should reduce time and clicks on service calls
  • Enhanced search engine matching rules should make it easier when using punctuation in the search.
  • Bulkified!   The previous limit of 100 SOQL queries has been raised to 20,000
  • Schedule multiple actions!
  • Bulkified! The previous limit of 100 SOQL queries has been raised to 20,000
  • Faster Org-Wide Default Sharing Recalculations
  • New: “Object-Specific Share Locks” – make multiple sharing rule changes without waiting for recalculation across all objects to complete.
  • Ability to Auto-Activate a refreshed sandbox

I hope you enjoyed the read. Please let me know if you have any other favourite features with Winter ’16 that I might have missed off.

Sunday, 11 October 2015

Winter 16 Release Notes for Developers

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.