Tuesday, December 13, 2016

Sample GROUP BY Clause in SOQL

Sample SOQL query to fetch case count based on the owner.

SELECT Owner.name, COUNT(CaseNumber)
FROM Case
GROUP BY Owner.name




Thank you...Enjoy!

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!

Friday, June 24, 2016

How To Write a SOQL To Fetch All Events Related to Account and Opportunity

Scenario:

Usually when we are writing any kind of SOQL queries on related objects we always known that this particular child record always be linked to specified parent object record. For example if you have a relationship between Account(Parent) and Contact(child) that means every contact record is related any one the account record not to any ABC__c or BCD__c objects.

But where in case of Task or Events if you could see we can't guarantee that these Tasks or Events are always related to a Account records or Contact Records because these Task or Events can be linked to any one of the Contract,Campaign,Account,Opportunity,Product,Asset,Case,Solution,Quote and Any Custom Objects .

Question:
In such type of situations the Task or Event that is linked to which object it's not a static and it's gets varies based on the Event that your creating for which object(Called as Polymorphic Relationship).Now If you want to fetch all Events related to Account and Opportunity only.How we need to write a SOQL query ?



Solution:

We already know that WhatId filed in Event or Task for deciding for which object this is linked /created.So with the help of TYPE qualifier on WhatId we can achieve this.The TYPE qualifier on field always determine the object type that is referenced for Task or Event.Use this TYPE clause on where condition of SOQL to control the result.

SELECT Id,subject,What.Type,whatId 
FROM Event
WHERE What.Type IN ('Account', 'Opportunity')

This above SOQL query returns all the Events related to Account and Opportunity only.


You can also apply comparison operators such as '=' or LIKE on WHERE condition of TYPE clause .


[SELECT Id,subject,What.Type,whatId 
FROM Event
WHERE What.Type like '%Accou%']

[SELECT Id,subject,What.Type,whatId 
FROM Event
WHERE What.Type ='Position__c']

They are multiple other ways also to do same.So we will discuss all those things in my next post.

Thanks for visiting...Enjoy!!!


What is Polymorphic Relationship in Salesforce ?

We are all very familiar with relationships in Salesforce right? Usually when we are discussing about relationships in salesforce immediately in our mind below listed relationship will appears

  • Lookup Relation Ship (Many-One relationship)
  • Master-detail Relationship  (Many-One relationship)
  • Many-to-Many Relationship
  • Self Relation Ship
But apart from this in salesforce we have one more relationship called Polymorphic Relationship.In all the above relationship (except Polymorphic Relationship) we always know that this particular child record always be linked to specified parent object record. For example if you have a relationship between Account(Parent) and Contact(child) that means every contact record is related any one the account record not to any ABC__c or BCD__c objects.

But where in case of Task or Events if you could see we can't guarantee that these Tasks or Events are always related to a Account records or Contact Records because these Task or Events can be linked to any one of the Contract,Campaign,Account,Opportunity,Product,Asset,Case,Solution,Quote and Any Custom Objects .These types of relationships is called as Polymorphic Relationship.In Polymorphic Relationship the referenced object of relationship can be any one of the Standard or Custom Objects.

Linking an attachment to any one of the custom object or standard object with the help of the Parent Id also refereed as Polymorphic Relationship only.

When your working with Polymorphic Relationship objects in SOQL we have several ways to access.

Follow my next to post to learn how to use this Polymorphic Relationship in SOQL.


Thanks for visiting....Enjoy!

Wednesday, June 22, 2016

25 Basic Deployment or Test Classes Issues During Deployment in Salesforce

1.System.DmlException: ConvertLead failed. First exception on row 0; first error: ENTITY_IS_DELETED, entity is deleted: []

2.System.NullPointerException: Argument 1 cannot be null

3.System.LimitException: Too many SOQL queries: 101

4.System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SampleTrigger: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a4980000001paQSAAY; first error:

5.first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SampleTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.SampleTrigger: line 181, column 1: [] Trigger.ChildTrigger: line 85, column 1 Trigger.ChildTrigger: line 50, column 1: []

6.System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OrderRequest: execution of AfterInsert caused by: System.DmlException: Process failed. First exception on row 0; first error: NO_APPLICABLE_PROCESS, No applicable approval process was found.: [] Trigger.OrderRequest: line 81, column 1: []

7.System.LimitException: Too many query rows: 50001

8.No such column 'Unique_Key__c' on entity 'End_Date_Ruleset__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

9.This custom field is referenced elsewhere in salesforce.com. : Field Updates.

10.Field Project_Quarter__c does not exist. Check spelling.

11.In field: field - no CustomField named Job_Profile__c.ID_to_get_cluster_value__c found

12.An object 'Lead-ETS/WMI Lead Page Layout' of type Layout was named in package.xml, but was not found in zipped directory

13.An object 'Lead.IsUKCreatedLead__c' of type CustomField was named in package.xml, but was not found in zipped directory

14.System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Update failed. First exception on row 0 with id 00Q8000001e17G8EAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UpdateAcctShippingAddr: execution of AfterUpdate caused by: System.LimitException: Too many SOQL queries: 101

15.Fatal Error null: The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later.

16.Invalid field Billing_Email__c for SObject Account

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

18.Stack Trace: Class.SendEmailQuote.generateEmailBody: line 941, column 1 Class.SendEmailQuote.<init>: line 151, column 1 Class.TestSendEmailQuote.Test1: line 73, column

19.Cannot update a field to a Lookup, MasterDetail, or Hierarchy from something else

20.Apex class 'QuoPDF_US' does not exist

21.Dependent class is invalid and needs recompilation: QuoPDF_US: line 58, column 20: Invalid type: Sales_Cond_Type__c

22.Invalid type: Sales_Type__c

23. new_quote does not exist or is not a valid override for action New.

24. Field is not writeable: Service_Order__c.CreatedById

25. Code Coverage Failure Your code coverage is 74%. You need at least 75% coverage to complete this deployment.


Thanks for visiting...Enjoy!

Method only allowed during testing" Error in Test Classes

Issue:

Lets take an example where you have a test class which contains Test.startTest() and Test.stopTest() methods and you have more than one test method in test class.When you run this test class in any way it touches any class that implements the Queueable interface your test classes methods more than one will fails

WorkAround:

Split all your test class methods into individual test class in salesforce. For more information please refer salesforce known issues page 


Thanks for visiting...Enjoy!

Issue with action support function on select of select list values

Today we had an issue with selection of pick-list. I am just trying to invoke a controller method when a user selects a pick list value from drop down and we are using an <apex:actionSupport> to make a call to the controller and the event is onchnage on onselect but unfortunately we are not able to make a call to controller method and the actionsupport with onselect or onchange in not working along with rerender also.



After a multiple hours of surfing over the internet we got some suggestion that just replace the onselect or onchnage with onclick event then it is started working and then after again reverted back to onselect or onchange now I'm able to make a call to controller method .I am not sure why is it working like that.

If you people are also facing the same issue just replace the your event onselect or onchange with onclick and try to invoke a controller method and if it's able to make a call to controller then again revert the onclick with onselect or onchange.

Thanks for visiting....Enjoy!