Search

Tuesday 31 May 2016

Useful Summer 16 Features


Cloning Sandboxes


You can now create a sandbox by cloning an existing sandbox rather than using your production org as your source. Save time by populating any type of sandbox with a previously chosen set of data and metadata. (Sandbox templates, which serve a similar purpose, are available only for Full or Partial Copy Sandboxes.) Sandbox-to-sandbox cloning facilitates iterative development, allowing you to freeze development in one sandbox and pick up where you left off in a new one. This feature is available in both Lightning Experience and Salesforce Classic.



Simplify Development of Asynchronous Callouts by Using Named Credentials


You can now use named credentials in long-running asynchronous callouts from a Visualforce page’s controller. A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. Salesforce manages all authentication for callouts that specify a named credential as the callout endpoint so that your Apex code doesn’t have to. You can also skip remote site settings, which are otherwise required for callouts to external sites, for the site defined in the named credential. This feature is available in both Lightning Experience and Salesforce Classic.




Get a Map of Populated SObject Fields


We’ve added a method on the Apex SObject class that makes it more efficient to iterate over fields that have been populated in memory. Previously, iterating over just the populated the fields of an SObject involved some complicated programming. For example, if you queried an SObject using SOQL, it wasn’t easy to tell which fields were returned. In Summer ’16, we’ve introduced a new method on the SObject class that returns a map of populated field names and their corresponding values:

Account a = new Account();
a.name = 'TestMapAccount1';
insert a;
a = [select Id,Name from Account where id=:a.Id];
Map fieldsToValue = a.getPopulatedFieldsAsMap();

for (String fieldName : fieldsToValue.keySet()){
    System.debug('field name is ' + fieldName + ', value is '
    + fieldsToValue.get(fieldName));
}

Admittedly the example by Salesforce above isn’t amazing but if the SOQL was a dynamic SOQL I can see a lot of benefit in this

You can also perform without a SOQL

Account a = new Account();
a.name = 'TestMapAccount1';
insert a;

Map fieldsToValue = a.getPopulatedFieldsAsMap();
for (String fieldName : fieldsToValue.keySet()){
   System.debug('field name is ' + fieldName + ', value is ' +      
   fieldsToValue.get(fieldName));
}



EmailTemplate Functions


RenderEmailTemplateBodyResult Class

getMergedBody() Returns the rendered body text with merge field references replaced with the corresponding record data.



System.Messaging Class

renderEmailTemplate(whoId, whatId, bodies)
Returns an array of RenderEmailTemplateBodyResult objects, each of which corresponds to an element in the
supplied array of text bodies. Each RenderEmailTemplateBodyResult provides a success or failure indication
along with either an error code or the rendered text.

renderStoredEmailTemplate(templateId, whoId, whatId)
Renders a text, custom, HTML, or Visualforce email template that exists in the database into an instance of
Messaging.SingleEmailMessage.




$Resource Global Value Provider And Lightning


The $Resource global value provider lets you reference images, style sheets, and JavaScript code you’ve uploaded in static resources. Using $Resource lets you reference assets by name, without worrying about the gory details of URLs or file paths. You can use $Resource in Lightning components markup and within JavaScript controller and helper code. To reference a specific resource in component markup, use $Resource.resourceName within an expression. Include CSS style sheets or JavaScript libraries into a component using the tag. To obtain a reference to a static resource in JavaScript code, use $A.get('$Resource.resourceName').




2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Note: only a member of this blog may post a comment.