Friday, July 15, 2016

Limitations of @InvocableMethod annotation in Salesforce

@InvocableMethod:

This Annotation will be used whenever you want to invoke an apex method from the Process Builder then that method must be declared as @InvocableMethod ,otherwise it can't be accessed in Process Builder .@InvocableMethod annotation have some limitations when your using it.

Limitations of @InvocableMethod Annotation:

  • Invocable method will not accept more than one argument as a method parameter
  • Only static methods can be invocable methods
  • More than one invocable method is not allowed per class

Method with Invocable Annotation Example:

public class UserHistoryProcessor
{
   @InvocableMethod 
  public static void updateUserHistory(List<Id> userIds)
  {
    //related code here
  }
 
}


Thanks for visiting...Enjoy!

How To Remove Length Menu Option From DataTables

Length menu option in Data Table will be used to decide how many number of rows to show in a single page .Please look at the below image to see the length menu


Solution:

To remove the that option we have to use below snippet of code

$(document).ready(function() {
    $('#htmlTableId').DataTable( {
        "bInfo" : false ,
         "bLengthChange" : false
    } );
} );


Output:



Thanks for visiting...Enjoy!

Salesforce Interview Questions -Compact Layouts

1. What is Compact Layout?

    The devices like in Mobile (Salesforce1) we will be running out with space constrains . So with the help of Compact Layouts we can  highlight the record key fields at glance .These layouts will help you to arrange necessary fields at record's highlight area.

2. If you haven't created compact layout what will happens in Salesforce1?

    It's not required to create a compact layout in salesforce .If you haven't created system will uses a predefined system generated read only compact layout

3. What fields will be included in default compact layouts?

    It will includes only Name field as part of compact layout

4. How many fields will be shown as part of record highlights section ?

   In Salesforce1 first 4 fields will be included
   In Lightning Experience first 5 fields will be included

5. How many fields you can add to Compact Layouts?

   10 fields

6. What are unsupported field types in compact layouts?
  • Text areas
  • Long text areas
  • Text areas
  • Multi-select pick lists
7. Can we assign different compact layouts to different users?
   
    No,only one compact layout will be assigned to all users

Thanks for visiting..hope this helps you!

Compact Layouts Salesforce Interview Questions

1. What is Compact Layout?

    The devices like in Mobile (Salesforce1) we will be running out with space constrains . So with the help of Compact Layouts we can  highlight the record key fields at glance .These layouts will help you to arrange necessary fields at record's highlight area.

2. If you haven't created compact layout what will happens in Salesforce1?

    It's not required to create a compact layout in salesforce .If you haven't created system will uses a predefined system generated read only compact layout

3. What fields will be included in default compact layouts?

    It will includes only Name field as part of compact layout

4. How many fields will be shown as part of record highlights section ?

   In Salesforce1 first 4 fields will be included
   In Lightning Experience first 5 fields will be included

5. How many fields you can add to Compact Layouts?

   10 fields

6. What are unsupported field types in compact layouts?
  • Text areas
  • Long text areas
  • Text areas
  • Multi-select pick lists
7. Can we assign different compact layouts to different users?
   
    No,only one compact layout will be assigned to all users

Thanks for visiting...Enjoy!


Business Scenarios That Are Not Supported in Lightning Experience

Salesforce Lightning Experience:

Each object in world will have it's own Pros and Cons .Based on the situations we have to pick the things which suits best for your functionality .Similarly Lightning Experience has it's own advantages as well as disadvantages compared to Salesforce Classic.At this point of time it's better saying not supported instead of framing it as a disadvantages because Salesforce Team is working very hard to bring all the features that supports in Salesforce Classic to Salesforce Lightning .It will take some time.

In this post I'm gone explain you some of the business scenarios that will support in Salesforce Classic and but not in Salesforce Lightning.
  • If your current business is related to Quotation generation with help of Standard Quotes in Salesforce that will not be supported in Salesforce Lightning .
  • If your Sales process team using any kind of forecasting mechanism to manage your company pipeline that will not supported in Salesforce Lightning.
  • If your sales team using Sales console to manage the multiple leads at a time that feature is also not available in Salesforce Lightning.
Above listed business scenarios are few examples .Please follow the same blog to find many other Pros and Cons related to Salesforce Lightning in upcoming posts.

Thanks for visiting...Enjoy!




Thursday, July 14, 2016

How To Enable/Disable Quick Access Menu Option In Salesforce

Quick Access Menu:

Quick Access Menu is nothing but an list of Quick options available to goto Object Detail page or to access Object fields ,Layouts and Record Types from a record detail page.This will be available on right hand side of the screen.

Please follow below steps to Enable/Disable in your org


Goto Setup-->Personal/Advance user Detail page and Enable Force.com Quick Menu Permison


Thanks for visiting....Enjoy!

How To Access Global Quick Actions in Salesforce Lightning Experience

Follow below steps to Access Global Quick Action in Lightning Experience

1. Goto Setup in LE and locate + plus symbol next to App Launcher



2. Click on Plus symbol to access available Global Quick Actions



3. Click on New Task to create a task from home page then in right hand side at bottom a form will be open to create a Task .Fill it and click save to create a quick Task



Thanks for visiting...Enjoy!

List of Annotations in Salesforce Apex

Usually Annotation means which will specifies the behavior or modifies the way how the particular class or method behaves in salesforce. Based on annotations the functionality or behavior and usage of particular class or method we can simply identify.

  • Each annotation will starts with '@' symbol and followed by name of the annotation
  • To declare a method/class with annotations it must be declared immediately before method/class  
Method with Annotation Example

public class UserHistoryProcessor
{
   @InvocableMethod 
  public static void updateUserHistory(List<Id> userIds)
  {
    //related code here
  }
 
}

List of Available Annotations in Apex

  • @isTest
  • @InvocableMethod
  • @InvocableVariable
  • @future
  • @AuraEnabled
  • @ReadOnly
  • @RemoteAction
  • @TestSetup
  • @TestVisible
  • @Deprecated
Apex REST annotations:
  • @RestResource(urlMapping='/yourUrl')
  • @HttpDelete
  • @HttpGet
  • @HttpPatch
  • @HttpPost
  • @HttpPut
we will discuss about each and every annotations with examples in next post please keep following the blog for latest updates

Thanks for visiting...Enjoy! 

How To Enable a Lightning Experience In Salesforce Orgs

Please follow the below steps to enable a lightning experience in Salesforce

1. Go to Setup---->In Left side navigation click on Lightning Experience link

 2. Go to Enable the New Salesforce Experience 

3. Draw as shown in image to enable the lightning experience


 4. Click on Finish Enabling Lightning Experience button to finsih it up.

5. Go to Setup--->Click on Switch to Lightning Experience link to open Lightning Experience



Thanks for visiting...Enjoy!

Salesforce1 Technical Support Is Not Available From Winter 17 on Selected IOS and Android Devices

As per the Salesforce Product notifications following Winter 17 Salesforce will not provide any kind of technical support or bugs raised on below listed devices running on Salesforce1 downloadable app or supported mobile browsers on which Salesforce1 can run.

List of the Devices 

  • iPhone 5
  • iPhone 5C
  • iPad Mini 2
  • iPad Mini 3
  • iPad 4
  • All Android phones except for Samsung Galaxy S5, S6 and S7; Samsung Galaxy Note 4 and Google Nexus 5X and Google Nexus 6P
  • All Android tablets except for Samsung Galaxy Note 10.1 and the Samsung Tab A 9.7

As per Salesforce notification it's planned from October 2016 it may or may not be changed based on Salesforce Release update.

For more information please visit below links

Thanks for visiting..Enjoy!

Wednesday, July 13, 2016

How to Change the Default Navigation Menu Items in Salesforce Lightning Experience.

We already started exploring on lightning experience ,which is an latest UI which will helps the Sales reps to access necessary data at glance to close more deals with lightning speed.In this post I will explain how to change the default navigation menu options in lightning experience.

Navigation Menu:

Below Screen shows what is meant by Navigation Menu in lightning experience .It usually contains all objects tabs.To change the tabs or to reorder the tabs in side navigation please follow further steps



1. Goto Setup--->Apps--->Navigation Menu--->Click on New button as shown below.


2.Enter Label Name and Description for Navigation Menu and click on Next button

3.Please Select/Deselect the Required Tabs from Available Items/Navigation Menu Items respectively


4.Please Select the list of Profiles to whom you want to apply these Navigation Menu



5.Click on Save and Finish Button and Reload the complete page and see the changes in Menu



Thanks for visiting...Enjoy!

List of the Editions That Supports Lightning Experience

As we already known that Salesforce have many types of editions to support for Small sized organisations to Large sized organisations.To understand whether your current org supports the lightning experience or not please look at the below table.


Supported Editions
Unsupported Editions
·         Group Edition
·         Professional Edition
·         Enterprise Edition
·         Performance Edition
·         Unlimited Edition
·         Developer Edition

·         Personal Edition
·         Contact Manager Edition
·         Database.com Edition
·         Chatter.com Edition



Thanks for visiting...Enjoy!

Tuesday, July 12, 2016

System.QueryException: List has no rows for assignment to SObject

Usually we will come across this type issue in many places and in many situations also .In the same way I have come across the same issue in one of the my class and I have done some work around it to fix this issue.I will explain this one with an example which may brings you an complete understanding about the issue.

Scenario:
I have 3 objects called Time_Track__c,Expert__c and User.Expert__c and User having a lookup relationship where User (Sforce_User__c) is acting as parent for Expert object and Time_Track__c and Expert__c also having lookup relationship where Time_Track__c is acting as child for Expert (Expert_Name__c) object .I have an visual force page which is using Time_Track__c  as a Standard Controller and I am having some extension class on same page .In the constructor of the extension class I am trying to query on Expert__c object based on logged in user to assign this expert to new time track as shown below

Source Code:
public class TrackExtn {
  public Time_Track__c timeTrack{get;set;} 

  public TrackExtn(ApexPages.StandardController controller) {
    timeTrack = new Time_Track__c();        
    timeTrack= (Time_Track__c)controller.getRecord();
       
    if(controller.getId()==null)
    {
       Expert__c exp = new Expert__c();
       //In below line you will receive List has no rows for assignment to SObject
       exp = [Select id from Expert__c where Sforce_User__c=:UserInfo.getUserId() limit 1];
       timeTrack.Expert_Name__c = exp!=null?exp.id:null;
           
    }

    }
}

Error:

When you execute the above code at run time if your having at least one matching Expert__c record for logged in user it will work very smoothly .If there is no matching Expert__c record for logged in user will end up with System.QueryException: List has no rows for assignment to SObject . Even if the matching record is not there it should continue fir the next lines with out throwing any error but here it's failing and terminating the complete execution. To handle this we need to follow below work around solution.


Workaround Solution:

We need to convert the Query result holder from SObject type to List<SObject> type that will resolve the issue .Please look at the below code for the work around solution

public class TrackExtn {
  public Time_Track__c timeTrack{get;set;} 

  public TrackExtn(ApexPages.StandardController controller) {
    timeTrack = new Time_Track__c();        
    timeTrack= (Time_Track__c)controller.getRecord();
      
    if(controller.getId()==null)
    {
        //Convert Sobject type to List<Sobject> type to store query result
        List<Expert__c> listexp =new List<Expert__c>();
        listexp = [Select id from Expert__c where Sforce_User__c =:UserInfo.getUserId() limit 1];
        System.debug('loggedinTech ..'+listexp );
        td.Technician__c = listexp.isEmpty()?null:listexp[0].id;
           
    }

    }
}

Thanks for visiting...Enjoy!

Monday, July 11, 2016

Sample Package.xml in ANT to Fetch Static Resources in Salesforce

Sample package.xml file to fetch Static Resources from Salesforce

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Please Type ResourceName</members>        
        <members>Favicon</members>
        <members>JQuery</members>
        <members>MobileMiniUKLtd_Logo</members>
        <name>StaticResource</name>
    </types>
    <version>30.0</version>
</Package>

Thanks for visiting...Enjoy!

Package.xml in ANT to Fetch Standard Objects in Salesforce

Sample package.xml file to fetch Opportunity Object

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Opportunity</members>
        <name>StandardObject</name>
    </types>
    <version>30.0</version>
</Package>


Thanks for visiting...Enjoy!

System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL.

Error:

Whenever your working with Dynamic SOQL construction you should be very careful regarding the Single Quotes(',') or Open/Close parentheses'(' ')'  and bind variables(':') in query string.If your also getting the same error as mentioned above please refer below code.

Source Code:

public void fetchOrders()
{
List<Order__c> listOrders = new List<Order__c>();
String selWOStatus ='Test'  // Usually value for this comes from visual force page

String q ='SELECT Id, Name, Location__c,End_Date__c,Createddate FROM Order__c where 
           Location__r.OwnerId=:'+UserInfo.getUserId();
                        
if('All'.equalsIgnoreCase(selWOStatus))
  q + = ' AND (Createddate =LAST_N_MONTHS:6 OR End_Date__c < NEXT_N_MONTHS:6) LIMIT 1000'; 

else
  q + =' AND (Status =\''+String.escapeSingleQuotes(selWOStatus)+'\' 
         AND Createddate = LAST_N_MONTHS:6) LIMIT 1000';

System.debug('q....'+q); 

listOrders  = Database.query(q);

System.debug('listTSOOrders....'+listOrders);

}

When you run this above code at run time you will end up with System.QueryException: Only variable references are allowed in dynamic SOQL/SOSL .This is due to the (':') bind variable usage in dynamic query construction which will cause the error and that causes missing a single quote for logged in user ID as shown query string coming at run time as shown below

Actual Query String at Run time:

'SELECT Id, Name, Location__c,End_Date__c,Createddate 
FROM Order__c 
where Location__r.OwnerId=:00560000004LFQkAAO 
AND (Status ='Test' AND Createddate = LAST_N_MONTHS:6) LIMIT 1000';

Excepted Query String at Run time:


'SELECT Id, Name, Location__c,End_Date__c,Createddate 
FROM Order__c 
where Location__r.OwnerId='00560000004LFQkAAO'
AND (Status ='Test' AND Createddate = LAST_N_MONTHS:6) LIMIT 1000';


Work Around Solution
Remove bind variable from query string and add single quotes before and after the user id

public void fetchOrders()
{
List<Order__c> listOrders = new List<Order__c>();
String selWOStatus ='Test'  // Usually value for this comes from visual force page

String qry ='SELECT Id, Name, Location__c,End_Date__c,Createddate FROM Order__c where 
           Location__r.OwnerId=\''+UserInfo.getUserId()+'\'';
                        
if('All'.equalsIgnoreCase(selWOStatus))
  qry + = ' AND (Createddate =LAST_N_MONTHS:6 OR End_Date__c < NEXT_N_MONTHS:6) LIMIT 1000'; 

else
  qry + =' AND (Status =\''+String.escapeSingleQuotes(selWOStatus)+'\' 
         AND Createddate = LAST_N_MONTHS:6) LIMIT 1000';

System.debug('qry....'+qry); 

listOrders  = Database.query(qry);

System.debug('listTSOOrders....'+listOrders);

}


Hope this helps you..Enjoy..!


Please comment or write us if you have any queries/requirements.

Please like,follow,bookmark,subscribe this site to receive daily updates.






How To Fetch Next 6 Months or Last 6 Months Records From Salesforce

If your trying to fetch records from Salesforce based on some date values likes today ,tomorrow,last few days/months/weeks/years or next few days/months/weeks/years we can make use of the Salesforce Date Literals to simplify the SOQL query as much as possible and each literal is a range of time beginning with midnight (12:00:00).



Below sample code will explains you how to build a dynamic SOQL query using NEXT_N_MONTHS and LAST_N_MONTHS date literals to fetch Next 6 months and Last 6 Months records from Salesforce.

Sample Code:


public void fetchOrders()
{
List<Order__c> listOrders = new List<Order__c>();
String selWOStatus ='Test'  // Usually value for this comes from visual force page

String qry ='SELECT Id, Name, Location__c,End_Date__c,Createddate FROM Order__c where 
           Location__r.OwnerId=\''+UserInfo.getUserId()+'\'';
                        
if('All'.equalsIgnoreCase(selWOStatus))
  qry +=' AND (Createddate =LAST_N_MONTHS:6 OR End_Date__c < NEXT_N_MONTHS:6) LIMIT 1000';
  
else if('Open'.equalsIgnoreCase(selWOStatus))
  qry +=' AND (End_Date__c < NEXT_N_MONTHS:6 AND (Status !=\'Closed\' AND 
         Status !=\'Canceled\' AND Status !=\'Converted\')) LIMIT 1000';
    
else
  qry +=' AND (Status =\''+String.escapeSingleQuotes(selWOStatus)+'\' 
         AND Createddate = LAST_N_MONTHS:6) LIMIT 1000';

System.debug('q....'+qry); 

listOrders  = Database.query(qry);

System.debug('listTSOOrders....'+listOrders);

}


Thanks for visiting...Enjoy!

Friday, July 8, 2016

How to Show Place Holder For Input Fields in Visual Force Page

Source Code


<apex:page standardController="Account">
    <apex:form >
    <apex:sectionHeader title="Place Holder in Salesforce"/>
      <apex:pageBlock title="Account Information">
       <apex:pageBlockSection >
           <apex:inputField value="{!account.name}" html-placeholder="I Love Coding...You?"/>
           <apex:inputField value="{!account.AccountNumber}" html-placeholder="478788788"/>
           <apex:inputField value="{!account.Site}" html-placeholder="srinivas4sfdc.com"/>
           <apex:inputField value="{!account.Fax}" html-placeholder="A77GHSH"/>
       </apex:pageBlockSection>         
      </apex:pageBlock>
    </apex:form>
  </apex:page>

Output




Thanks for visiting...Enjoy!

Salesforce Certification Expiration Warning


As per the Salesforce notification July 8, 2016 is the last day to finish Salesforce Certified Force.com Developer - Winter '16 Release Exam . To prevent your credential(s) from expiring, you must successfully complete Winter '16 Release Exam release exams by July 8, 2016.


For Latest winter 16 dumps visit my previous post


So please don't forget to finish all your maintenance exams before it's got expired


Thanks for visiting.....All the best




System.StringException: Invalid id Error in Salesforce

Usually this kind of error we will be receiving in test classes.This is due to when your working with any kind of relationship fields in objects.Let me explain with an example below

Error:

We have a two objects called Order__c and Time__c and these two objects are having a lookup relationship where Order__c is Child and Time__c is a parent.Now i have to create a test record for Time__c along with Order__c and then I want to update Time__c record Order__c with null value.
@isTest 
private class TestTimeEntry {
    static testMethod void validateTime() {
        Order__c ord = new Order__c();
        ord.Name ='Test Order';
        insert ord;
        
        Time__c tm1 = new Time__c();
        tm1.Order__c = ord.id;
        tm1.name = 'test time';
        insert tm1;
        
        Time__c tm2 =[Select id,name,Order__c from Time__c where id=:tm1.id];
        tm2.Order__c =''; //At runtime we will receive Error here
        update tm2;
    }
}

Root Cause:

So when you run this test class you will receive a runtime error called System.StringException: Invalid id  at an update statement due to assigning an empty string(empty space) to Order__c.Usually all relationship fields will accepts Ids or null key word. 

Work Around Solution
So when your trying to assign an empty value for relationship field we have to specify null keyword instead of an empty space('')
@isTest 
private class TestTimeEntry {
    static testMethod void validateTime() {
        Order__c ord = new Order__c();
        ord.Name ='Test Order';
        insert ord;
        
        Time__c tm1 = new Time__c();
        tm1.Order__c = ord.id;
        tm1.name = 'test time';
        insert tm1;
        
        Time__c tm2 =[Select id,name,Order__c from Time__c where id=:tm1.id];
        tm2.Order__c =null; //An empty space replaced with null keyword
        update tm2;
    }
}



Thanks for visiting...Enjoy!


Spring 16 Salesforce Developer 401 Maintenance Exam Questions

1.Which standard field can be updated using formula rules in process builder?
  • Created Date 
  • Owner ID
  • Deleted
  • ID

2.What must be true when accessing a user's private reports and dashboards?Choose 2 answers
  • Having the "Manage All Private Reports and Dashboards" permission.
  • Using the "allPrivate" with the "scope" condition in a SOQL query.
  • Using the "allPrivate" with the "where" condition in a SOQL query.
  • Having the "Administrator Access to Private Files" permission.

3.What is true about Data Loader?Choose 3 answers
  • It can be used with SAML Authentication.
  • It can be used with both Mac and PC.
  • It can be used with OAuth Authentication
  • It can be used with Password Authentication.
  • It can be used with only a PC.

4.Which Quick Actions can contain a "Custom Success Message?"Choose 2 answers
  • Visit a website
  • Update a Record
  • Log a Call
  • Send an Email

5.What is true about the file sharing "Set by Record?"
  • It is used to infer sharing via the record type.
  • It is used to infer sharing via the parent record
  • It is used to infer sharing via the record owner
  • It is used to infer sharing via the associated record.

Thanks for visiting...Enjoy

Wednesday, July 6, 2016

Winter 16 Salesforce Developer Maintenance Exam Questions

1. In a Salesforce organization using state and country picklists, what feature allows a Lightning Experience user to choose the correct address when entering information in a standard address field?
  • Auto-completion for standard address fields.
2. What is an enhancement to Process Builder? Choose 2 answers
  • Administrators receive a fault email when a process fails due to user inactivity 
  • More than one schedule can be enabled for a single action 

3. What is an enhancement to Salesforce Files? Choose 2 answers
  • A file owner can freeze a file to prevent additional shares of the file.
  • An administrator can control whether users can upload files from Salesforce.

4. What is an enhancement to working with records in Chatter Groups? Choose 2 answers
  • When a group is @mentioned on a record, that record becomes a Group Record.
  • Group Records are displayed in the groups related lists.

5. By default, which users have access to Lightning Experience once it has been enabled?
  • All users with Standard Salesforce profiles

Thanks for visiting...Enjoy!

Friday, July 1, 2016

Stronger Security is Required Issue when logging into Sandbox

Issue:

Stronger Security is Required Issue when logging into Sandbox


When you try to login into sandbox from June 25 ,2016 on wards and if you end of  with an error called Stronger security is required, don't worry please read the below instructions to resolve it


Root Causes

This is due to the below reasons

  • As per the salesforce notifications they will stop supporting TLS 1.0 and automatically all sandboxes will be upgraded to TLS 1.1 from June 25,2016 .
  • All the production orgs will be upgraded to TLS 1.1 from March 4,2017.
  • So when your trying to login into sandbox from the browsers that will not support this TLS 1.1 will end up with this error and you will not be able to proceed further

WorkAround 

We need to make sure that the browser that your using will support TLS 1.1 and higher, if not you need to update the browser version or manually we need to enable TLS 1.1  to support it.

Action Required for Browser Compatibility
  • Google Chrome - Chrome 38 and Higher will support TLS 1.1 by default
  • Mozilla Firefox - FireFox 27 and Higher will support TLS 1.1 by default
  • IE  - Desktop and mobile IE version 11 will support TLS 1.1 by default
For more information refer salesforce notes at below links
Thanks for visiting...Enjoy!