Saturday, 8 December 2018

Convert 15 character IDs to 18 character IDs in formula field

Hi ,

We have new method "CASESAFEID()"in formula field now to make 15 character Id to 18 character.

Classic
1. Go to Setup | Customize | object name | click Fields
a. For Custom objects: Setup Create Objects | object name
3. In the related list "Custom Fields & Relationships" click New.
4. Click the Formula radio button.
5. Click the Text radio button for 'Formula Return Type.'
6. Input the following Formula into the Formula Editor:
CASESAFEID(Id)

7. Set Field Visibility, add or remove from the page layout.
 8. Click Save.

Lightning
 
1. Go to Setup Object Manager | Object name | Fields & Relationships
2. Click New.
3. Click the Formula radio button.
4. Click the Text radio button for 'Formula Return Type.'
5. Input the following formula into the Formula Editor:
CASESAFEID(Id)

6. Set Field Visibility, add or remove from the page layout.
7. Click Save.


Reference:
https://help.salesforce.com/articleView?id=000005288&language=en_US&type=1

Sunday, 25 November 2018

Run Script After Sandbox Creation and Refresh

Hi ,
We have an interface SandboxPostCopy from salesforce.com to do data manipulation after sandbox is created or refresh.
It makes our  sandbox environment business ready, automate data manipulation or business logic tasks.
At sandbox creation, specify a single Apex class to perform the tasks. This class executes every time the sandbox is copied.
Lightning interface of sandbox post-copy script specification

Create an Apex class that implements SandboxPostCopy and specify the class here. For example, the following Apex class simply reports the three contexts available in SandboxPostCopy: your organization ID, sandbox ID, and sandbox name:
Example:
global class HelloWorld implements SandboxPostCopy {
  global void runApexClass(SandboxContext context) {
      System.debug('Hello Tester Pester ' + context.organizationId()
           + ' ' + context.sandboxId() + context.sandboxName()); 
    }
  }

you can write your business logic in the method "runApexClass"

Reference:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_System_SandboxPostCopy.htm?search_text=SandboxPostCopy#apex_interface_System_SandboxPostCopy_Example
https://docs.releasenotes.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm





Monday, 19 November 2018

SFDX with Non Scratch Orgs

Hi ,

Gave demo on SFDX with Non Scratch orgs in our Salesforce Techbook Channel. You can learn how to use SFDX with Non Scratch orgs after this demo.





References:

https://trailhead.salesforce.com/en/content/learn/trails/sfdx_get_started
SFDX CLI:https://developer.salesforce.com/tools/sfdxcli
VS Code:https://code.visualstudio.com/download
Salesforce Extensions:
https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode






Monday, 12 November 2018

Software installations for SFDX setup

Hi ,

We need to setup the following software in the order mentioned



1)Install Java8 (jdk 8)  and set path
2)Install SFDXCLI "https://developer.salesforce.com/tools/sfdxcli" and set path
3)Install VS Code
4)Install "Salesforce Extension Pack" in VS code  (Under extensions section search for Salesforce Extensions for Visual Studio Code)



Reference:

https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm#sfdx_setup_install_cli

Sunday, 14 October 2018

Get Record Type Id from lightning component in standard new action override (getting any url parameter)

Hi ,

Here we have requirement to get record type id from lightning component when standard "New" action is overrided.


To get selected RecordTypeId from the component we have to implement the lightning interface "lightning:isUrlAddressable" which will be useful to access parameter "RecordTypeId" from the top level.


Eg:

Ligthtning Component:
----------------------------

<aura:component implements="lightning:isUrlAddressable" description="c:helloTarget component">
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    Hello {!v.firstname}.
</aura:component>

JavascriptController:
-------------------------
({
    init: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.RecordTypeId;
        cmp.set("v.firstname", firstname);
    }
})



References:
---------------
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation



lightning:workspaceAPI on Lightning Console Applications (Getting record id from record tab)

Hi ,

To access tabs or sub tabs information in Salesforce Classic console application we have Console Integration Toolkit.
In the same way to access tabs or sub tabs information in Lightning Conosle Application we have to use "workspaceAPI".
To access methods of "workspaceAPI" we have to create an instance of the lightning:workspaceAPI component and assign an aura:id attribute to it as shown below .

<lightning:workspaceAPI aura:id="workspace"/>

This component allows you to access methods for programmatically controlling workspace tabs and subtabs in a Lightning console app. In Lightning console apps, records open as workspace tabs and their related records open as subtabs.

Scenario:
When a record is opened in Lighning Console application  we should be able to find out the record ID from the record tab, for further process from application utility menu items.

Eg:


<aura:component                  implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable" 
                access="global"  controller="UpdateCaseController">
    <lightning:workspaceAPI aura:id="workspace" />

    <aura:attribute name="recordId" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>


JSController:

({
doInit : function(component, event, helper) {
        
        var workspaceAPI = component.find("workspace");
        workspaceAPI.getTabInfo().then(function(response) {
                       var action = component.get("c.updateCase");        
                       action.setParams({"caseRecordId":response.recordId});
                       action.setCallback(this,function(data){
                             var result = data.getReturnValue();
                              
                     });
                    $A.enqueueAction(action);
        });
})

Apex Controller:

public class UpdateCaseController{
  @Auraenabled
   public static void updateCase(String caseRecordId){
       Case caseObj = new Case(Id=caseRecordId,ownerId=UserInfo.getUserId());
        update caseObj;
   }
   

}


Reference:

https://developer.salesforce.com/docs/component-library/bundle/lightning:workspaceAPI/documentation

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_methods_lightning_tabs.htm





Saturday, 29 September 2018

Lightning Data Service Considerations (limitations)

Hi,

We have few limitations on Lightning Data Service. We have to consider these before we use the same for any implementation.

Lightning Data Service is powerful and simple to use. However, it’s not a complete replacement for writing your own data access code. Here are some considerations to keep in mind when using it.
Lightning Data Service is only available in Lightning Experience and the Salesforce app. Using Lightning Data Service in other containers, such as Lightning Components for Visualforce or Lightning Out, isn’t supported. This is true even if these containers are accessed inside Lightning Experience or the Salesforce mobile app, for example, a Visualforce page added to Lightning Experience.

Lightning Data Service supports primitive DML operations—create, read, update, and delete. It operates on one record at a time, which you retrieve or modify using the record ID. Lightning Data Service supports spanned fields with a maximum depth of five levels. Support for working with collections of records or for querying for a record by anything other than the record ID isn’t available. If you must support higher-level operations or multiple operations in one transaction, use standard @AuraEnabled Apex methods.

Lightning Data Service shared data storage provides notifications to all components that use a record whenever a component changes that record. It doesn’t notify components if that record is changed on the server, for example, if someone else modifies it. Records changed on the server aren’t updated locally until they’re reloaded. Lightning Data Service notifies listeners about data changes only if the changed fields are the same as in the listener’s fields or layout.





Reference:

https://trailhead.salesforce.com/modules/lightning_data_service/units/lightning_data_service_get_started

https://developer.salesforce.com/docs/atlas.en-us.214.0.lightning.meta/lightning/data_service_considerations.htm

Sunday, 26 August 2018

Salesforce Techbook (New Youtube Channel)

Hi ,

Have started new youtube channel "Salesforce Techbook" for providing useful examples.The following video published on "Salesforce Techbook" channel. Interested people can subscribe.

Please find the below URL (lightning component development):

https://www.youtube.com/watch?v=xMzPhu01ptc&lc=z22ihbcbwuqbzzwxf04t1aokgsnmccfanmrqqukxt4pabk0h00410

Channel URL:

https://www.youtube.com/channel/UCipDch4PvPqm0uY4SK7mi1A

Future Concepts:

https://www.youtube.com/watch?v=HA7-gkQH2bE

All the best

Interface Reference of Lightning


Implement these platform interfaces to allow a component to be used in different contexts, or to enable your component to receive extra context data. A component can implement multiple interfaces. Some interfaces are intended to be implemented together, while others are mutually exclusive. Some interfaces have an effect only in Lightning Experience and the Salesforce app.

Interfaces belong to different namespaces, including:

clients
Provides interfaces that are specific to Lightning for Outlook or Lightning for Gmail.
flexipage
Provides interfaces that are specific to Lightning Pages and the Lightning App Builder.
force
Provides interfaces that are specific to Lightning Experience and the Salesforce app.
forceCommunity
Provides interfaces that are specific to Communities.
lightning
Provides interfaces that are specific to Lightning Experience, the Salesforce app, and Communities.
ltng
Provides events that are handled by Lightning Out.
Some of these interfaces are summarized below. For a complete list, refer to the Component Library.

clients:availableForMailAppAppPage
To appear in the Lightning App Builder or a Lightning Page in Lightning for Outlook or Lightning for Gmail, a component must implement the clients:availableForMailAppAppPage interface. 
clients:hasEventContext
Enables a component to be assigned to an event’s date or location attributes in Lightning for Outlook and Lightning for Gmail. 
clients:hasItemContext
Enables a component to be assigned to an email’s or a calendar event’s item attributes in Lightning for Outlook and Lightning for Gmail.
flexipage:availableForAllPageTypes
A global interface that makes a component available in the Lightning App Builder, and for any type of Lightning page.
flexipage:availableForRecordHome
If your component is designed only for record pages, implement the flexipage:availableForRecordHome interface instead of flexipage:availableForAllPageTypes
forceCommunity:availableForAllPageTypes
To appear in Community Builder, a component must implement the forceCommunity:availableForAllPageTypes interface. 
force:appHostable
Allows a component to be used as a custom tab in Lightning Experience or the Salesforce app. 
force:lightningQuickAction
Allows a component to display in a panel with standard action controls, such as a Cancel button. These components can also display and implement their own controls, but should handle events from the standard controls. If you implement force:lightningQuickAction, you can’t implement force:lightningQuickActionWithoutHeader within the same component.
force:lightningQuickActionWithoutHeader
Allows a component to display in a panel without additional controls. The component should provide a complete user interface for the action. If you implement force:lightningQuickActionWithoutHeader, you can’t implement force:lightningQuickAction within the same component. 
ltng:allowGuestAccess
Add the ltng:allowGuestAccess interface to your Lightning Out dependency app to make it available to users without requiring them to authenticate with Salesforce. This interface lets you build your app with Lightning components, and deploy it anywhere and to anyone. 

References:
https://developer.salesforce.com/docs/component-library/overview/interfaces
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_interfaces.htm


Thursday, 26 July 2018

Get the Developer Name for Record Types without SOQL query

Hi,

Previously, the developer name was accessible only via SOQL on the RecordType SObject, and not via describe information. Now you can use the following methods to get the developer name.


  • Schema.DescribeSObjectResult.getRecordTypeInfosByDeveloperName()
  • Schema.RecordTypeInfo.getDeveloperName()


Sample Codes:

Getting Record Type Id based on Developer Name:

Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names of Department__c object
Map<String,Schema.RecordTypeInfo>  recordTypeInfo = resSchema.getRecordTypeInfosByDeveloperName(); 
//Getting IT Department Record Type Id by using developer name ''IT_Department"
Id recordTypeId= recordTypeInfo.get('IT_Department').getRecordTypeId();
System.debug('recordTypeId:'+recordTypeId);

Getting RecordType Developer Name based on Name(Label):


Schema.DescribeSObjectResult resSchema = Department__C.sObjectType.getDescribe();
//getting all Recordtype developer names Account
Map<String,Schema.RecordTypeInfo> recordTypeInfo = resSchema.getRecordTypeInfosByName(); 
//Getting Business Record Type Id by using developer name 
String developerName = recordTypeInfo.get('IT Department').getDeveloperName();

System.debug('developerName:'+developerName);


Reference:

https://trailhead.salesforce.com/modules/platform_dev_i_cert_maint_sum18/units/whats_new_platform_devs


Thursday, 21 June 2018

Refresh Interval of different types of Sandboxes

Hi,

We have different refresh intervals for different sandboxes as shown below.

Sandbox Type
Refresh Interval
Storage Limit
What’s Copied
Developer Sandbox
1 day
Data storage: 200 MB
File storage: 200 MB
Metadata only
Developer Pro Sandbox
1 day
Data storage: 1 GB
File storage: 1 GB
Metadata only
Partial Copy Sandbox
5 days
Data storage: 5 GB
File storage: 5 GB
Metadata and sample data
Full Sandbox
29 days
Same as your production org
Metadata and all data


Reference:

https://trailhead.salesforce.com/modules/app_deployment/units/app_deployment_sandbox?trailmix_creator_id=00550000006yDdKAAU&trailmix_id=architect-dev-lifecycle-and-deployment

Convert 15 character IDs to 18 character IDs in formula field

Hi , We have new method " CASESAFEID() "in formula field now to make 15 character Id to 18 character. Classic 1. Go to  Se...