September 29, 2016
September 28, 2016
How to query data which was modified in specific time limit in Salesforce?
Below is the SOQL to query data which was modified between 4 PM and 6 PM.
Sample SOQL:
SELECT Id, LastModifiedDate FROM Account WHERE LastModifiedDate = TODAY AND HOUR_IN_DAY(LastModifiedDate) >= 16 AND HOUR_IN_DAY(LastModifiedDate) < 18
Cheers!!!
Sample SOQL:
SELECT Id, LastModifiedDate FROM Account WHERE LastModifiedDate = TODAY AND HOUR_IN_DAY(LastModifiedDate) >= 16 AND HOUR_IN_DAY(LastModifiedDate) < 18
Cheers!!!
September 27, 2016
LIKE operator in SOQL against set of strings
Sample Code:
Set < String > filterOptions = new Set < String > {'Test%', 'Sample%', '%Temp%'}
List < Accont > listAccts = [ SELECT Id FROM Account WHERE Name LIKE : filterOptions ];
Cheers!!!
Set < String > filterOptions = new Set < String > {'Test%', 'Sample%', '%Temp%'}
List < Accont > listAccts = [ SELECT Id FROM Account WHERE Name LIKE : filterOptions ];
Cheers!!!
September 26, 2016
Help text for apex:inputField
Sample Code:
Visualforce Page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem helpText="Name of the Account" >
Account Name <apex:inputField value="{!acct.Name}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class Sample {
public Account acct {get;set;}
public Sample() {
}
}
Output:
Cheers!!!
Visualforce Page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem helpText="Name of the Account" >
Account Name <apex:inputField value="{!acct.Name}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class Sample {
public Account acct {get;set;}
public Sample() {
}
}
Output:
Cheers!!!
September 25, 2016
September 23, 2016
Salesforce error validating object - Data Loader Issue
It's a known issue from Salesforce.
Check the below link for more information
https://success.salesforce.com/issues_view?id=a1p300000008YH8AAM
Logout and log in again. It worked for me.
Click "This Affects Me", so that you will get an update once the issue is resolved.
Cheers!!!
Check the below link for more information
https://success.salesforce.com/issues_view?id=a1p300000008YH8AAM
Logout and log in again. It worked for me.
Click "This Affects Me", so that you will get an update once the issue is resolved.
Cheers!!!
September 22, 2016
Salesforce Interview Questions with Answers Part 37
1. What is the use Queueable Interface?
http://www.infallibletechie.com/2016/08/queueable-apex.html
2. What is the use of Apex Flex queue?
http://www.infallibletechie.com/2016/08/flex-queue.html
3. Why objects can’t be passed as arguments to future methods in Salesforce?
http://www.infallibletechie.com/2016/08/why-objects-cant-be-passed-as-arguments.html
4. What are all the mock HTTPCallOuts available in Salesforce?
http://www.infallibletechie.com/2016/08/what-are-all-mock-httpcallouts.html
5. How to write test class for HTTPCallouts in Salesforce?
http://www.infallibletechie.com/2016/08/how-to-write-test-class-for.html
6. Difference between Clone and DeepClone in Apex in Salesforce
http://www.infallibletechie.com/2014/08/difference-between-clone-and-deepclone.html
7. Simple HTTP Class in Salesforce
http://www.infallibletechie.com/2016/08/simple-http-class-in-salesforce.html
8. What is the use of ApexPages.currentPage().getUrl()?
http://www.infallibletechie.com/2016/09/apexpagescurrentpagegeturl.html
9. What is the main purpose of System.runAs()?
System.runAs() is mainly for record sharing. It is not for user permissions and field level permissions.
10. How to insert child record using Parent record's External Id field?
http://www.infallibletechie.com/2016/09/how-to-insert-child-record-using-parent.html
11. How to query Knowledge Article Type object?
Object Name - FAQ
API Name - FAQ__kav
Default object created is Knowledge(API Name is Knowledge__kav)
12. Junction object between Article type and Case?
CaseArticle
13. Related list in Case for attaching Articles?
Articles - Related List
Find articles - Button
14.Community Licenses
Do your community members need access to:
Reports and dashboards
Delegated admin
Content libraries
Records across accounts
Then you probably need Customer Community Plus Licenses.
In addition to the above, do your community members also need access to:
Leads and opportunities
Campaigns
Then you probably need Partner Community Licenses.
Customer Community Licenses get a basic pass, just like an economy ticket. Customer Community Plus Licenses get more access, like business travelers. Partner Community Licenses? Well, they get way more access, pretty much like first-class travelers.
15. What is the use of Sharing Set in Community?
A sharing set gives community users access to records that are associated with their accounts or contacts based on their user profiles.
http://www.infallibletechie.com/2016/09/what-is-use-of-sharing-set-in.html
16. How to Reputation Levels in Salesforce Community?
http://www.infallibletechie.com/2016/09/how-to-reputation-levels-in-salesforce.html
17. How to change logo in Community?
Go to Login & Registration and click "Choose File" in Header logo to select the picture from the computer.
18. How to make sure Person Account is created when users sign up for community in Self Registration?
In the Login & Registration, default account should be blank.
Cheers!!!
http://www.infallibletechie.com/2016/08/queueable-apex.html
2. What is the use of Apex Flex queue?
http://www.infallibletechie.com/2016/08/flex-queue.html
3. Why objects can’t be passed as arguments to future methods in Salesforce?
http://www.infallibletechie.com/2016/08/why-objects-cant-be-passed-as-arguments.html
4. What are all the mock HTTPCallOuts available in Salesforce?
http://www.infallibletechie.com/2016/08/what-are-all-mock-httpcallouts.html
5. How to write test class for HTTPCallouts in Salesforce?
http://www.infallibletechie.com/2016/08/how-to-write-test-class-for.html
6. Difference between Clone and DeepClone in Apex in Salesforce
http://www.infallibletechie.com/2014/08/difference-between-clone-and-deepclone.html
7. Simple HTTP Class in Salesforce
http://www.infallibletechie.com/2016/08/simple-http-class-in-salesforce.html
8. What is the use of ApexPages.currentPage().getUrl()?
http://www.infallibletechie.com/2016/09/apexpagescurrentpagegeturl.html
9. What is the main purpose of System.runAs()?
System.runAs() is mainly for record sharing. It is not for user permissions and field level permissions.
10. How to insert child record using Parent record's External Id field?
http://www.infallibletechie.com/2016/09/how-to-insert-child-record-using-parent.html
11. How to query Knowledge Article Type object?
Object Name - FAQ
API Name - FAQ__kav
Default object created is Knowledge(API Name is Knowledge__kav)
12. Junction object between Article type and Case?
CaseArticle
13. Related list in Case for attaching Articles?
Articles - Related List
Find articles - Button
14.Community Licenses
Do your community members need access to:
Reports and dashboards
Delegated admin
Content libraries
Records across accounts
Then you probably need Customer Community Plus Licenses.
In addition to the above, do your community members also need access to:
Leads and opportunities
Campaigns
Then you probably need Partner Community Licenses.
Customer Community Licenses get a basic pass, just like an economy ticket. Customer Community Plus Licenses get more access, like business travelers. Partner Community Licenses? Well, they get way more access, pretty much like first-class travelers.
15. What is the use of Sharing Set in Community?
A sharing set gives community users access to records that are associated with their accounts or contacts based on their user profiles.
http://www.infallibletechie.com/2016/09/what-is-use-of-sharing-set-in.html
16. How to Reputation Levels in Salesforce Community?
http://www.infallibletechie.com/2016/09/how-to-reputation-levels-in-salesforce.html
17. How to change logo in Community?
Go to Login & Registration and click "Choose File" in Header logo to select the picture from the computer.
18. How to make sure Person Account is created when users sign up for community in Self Registration?
In the Login & Registration, default account should be blank.
Cheers!!!
style not working apex:outputtext
Sample Code:
<apex:outputText style="font-size:10px; font-weight:bold; color:red;" value="Testing Style in outputtext tag."/>
In the below code, style won't be applied.
<apex:outputText style="font-size:10px; font-weight:bold; color:red;">Testing</apex:outputText>
Cheers!!!
<apex:outputText style="font-size:10px; font-weight:bold; color:red;" value="Testing Style in outputtext tag."/>
In the below code, style won't be applied.
<apex:outputText style="font-size:10px; font-weight:bold; color:red;">Testing</apex:outputText>
Cheers!!!
September 21, 2016
The Sharing Set is not setup with proper Case access Salesforce Trailhead
If you face "The Sharing Set is not setup with proper Case access" in Salesforce Trailhead, kindly do the following
1. Create a Case under the Account to which the Contact Edna Frank was created.
2. Enable External Sharing Model in Sharing Settings.
3. Set the Default External Access for Case object to Private.
1. Create a Case under the Account to which the Contact Edna Frank was created.
2. Enable External Sharing Model in Sharing Settings.
3. Set the Default External Access for Case object to Private.
What is the use of Sharing Set in Salesforce Community?
A sharing set gives community users access to records that are associated with their accounts or contacts based on their user profiles.
Note:
The Available Objects list excludes:
Objects with an organization-wide sharing setting of Public Read/Write
Custom objects that don’t have an account or contact lookup field
1. Go to Customer Portal Settings.
2. Click New in Sharing Sets section.
3. Give any label and name. Select the Profile, set up the objects and select the access level.
Note:
The Available Objects list excludes:
Objects with an organization-wide sharing setting of Public Read/Write
Custom objects that don’t have an account or contact lookup field
1. Go to Customer Portal Settings.
2. Click New in Sharing Sets section.
3. Give any label and name. Select the Profile, set up the objects and select the access level.
September 20, 2016
September 19, 2016
SOQL to get attachments from Specific object
Sample SOQL:
SELECT Id FROM Attachment WHERE ParentId IN ( SELECT Id FROM Account )
The above SOQL fetches all the attachments ids from Account object.
Cheers!!!
SELECT Id FROM Attachment WHERE ParentId IN ( SELECT Id FROM Account )
The above SOQL fetches all the attachments ids from Account object.
Cheers!!!
September 16, 2016
Implementation Restriction while querying Article Types
Always add language='en_US' AND publishstatus ='online' in the Query.
Sample Query:
String strSOQL = 'SELECT Id, ArticleNumber, Title, LastModifiedDate, CreatedBy.Name FROM Knowledge__kav WHERE language=\'en_US\' AND publishstatus = \'online\'';
Check the below link for more info
https://help.salesforce.com/apex/HTViewSolution?id=000113362&language=en_US
Cheers!!!
Sample Query:
String strSOQL = 'SELECT Id, ArticleNumber, Title, LastModifiedDate, CreatedBy.Name FROM Knowledge__kav WHERE language=\'en_US\' AND publishstatus = \'online\'';
Check the below link for more info
https://help.salesforce.com/apex/HTViewSolution?id=000113362&language=en_US
Cheers!!!
September 15, 2016
Service Cloud Launch Pad
Launch Pad lets you deploy and test key Service Cloud features in your sandbox quickly and easily.
Standard Console
If you want the latest and greatest of the console, this is the template for you. It includes the most-used console features, including keyboard shortcuts, the footer component, multi-monitor support and the ability to pin tabs. It also includes the most popular Service Cloud objects, including Cases, Accounts, Contacts, Reports and Dashboards.
Branded Console
Get all the features of Standard Console, plus the ability to easily customize it with your company logo and branding scheme.
Service Reports & Dashboards
Deploy a suite of preconfigured reports and dashboards to help you track your service-center metrics. When deployed, these are automatically added to your org. (The ability to view them is determined by each user’s access to Reports and Dashboards.)
1. Go to Service Cloud Launch Pad.
2. Select any template.
3. Give any name to the App.
4. Click View to view the app and Customize to modify the app.
Cheers!!!
Standard Console
If you want the latest and greatest of the console, this is the template for you. It includes the most-used console features, including keyboard shortcuts, the footer component, multi-monitor support and the ability to pin tabs. It also includes the most popular Service Cloud objects, including Cases, Accounts, Contacts, Reports and Dashboards.
Branded Console
Get all the features of Standard Console, plus the ability to easily customize it with your company logo and branding scheme.
Service Reports & Dashboards
Deploy a suite of preconfigured reports and dashboards to help you track your service-center metrics. When deployed, these are automatically added to your org. (The ability to view them is determined by each user’s access to Reports and Dashboards.)
1. Go to Service Cloud Launch Pad.
2. Select any template.
3. Give any name to the App.
4. Click View to view the app and Customize to modify the app.
Cheers!!!
September 9, 2016
September 8, 2016
How to insert child record using Parent record's External Id field?
Sample Code:
Hobby__c h = new Hobby__c(Name = 'Test');
h.Employee__r = new Employee__c(Employee_Primary_Email__c = 'testing@test.com');
insert h;
here Employee__c is the field which is a lookup to Employee__c object and Employee_Primary_Email__c is the External Id field.
Cheers!!!
Hobby__c h = new Hobby__c(Name = 'Test');
h.Employee__r = new Employee__c(Employee_Primary_Email__c = 'testing@test.com');
insert h;
here Employee__c is the field which is a lookup to Employee__c object and Employee_Primary_Email__c is the External Id field.
Cheers!!!
What is the use of apex:message?
A message for a specific component, such as a warning or error. If an <apex:message> or <apex:messages> component is not included in a page, most warning and error messages are only shown in the debug log.
Visualforce page:
<apex:inputField value="{!account.NumberOfEmployees}" id="Employee_validation"/>
<apex:message for="Employee_validation" />
Apex Class:
ApexPages.addMessages(exception);
Cheers!!!
Visualforce page:
<apex:inputField value="{!account.NumberOfEmployees}" id="Employee_validation"/>
<apex:message for="Employee_validation" />
Apex Class:
ApexPages.addMessages(exception);
Cheers!!!
How to get Standard Price Book Id in test class?
Test.getStandardPricebookId() is used to get Standard Price Book Id in test class.
Sample Code:
Id pricebookId = Test.getStandardPricebookId();
Cheers!!!
Sample Code:
Id pricebookId = Test.getStandardPricebookId();
Cheers!!!
What field type can be used in the WHERE clause to improve SOQL query performance in Salesforce?
The following fields are indexed by default:
1. Primary keys (Id, Name and Owner fields).
2. Foreign keys (Lookup or Master-Detail relationship fields).
3. Audit dates (such as SystemModStamp).
4. Custom fields marked as External ID or Unique.
Cheers!!!
1. Primary keys (Id, Name and Owner fields).
2. Foreign keys (Lookup or Master-Detail relationship fields).
3. Audit dates (such as SystemModStamp).
4. Custom fields marked as External ID or Unique.
Cheers!!!
ApexPages.currentPage().getUrl()
ApexPages.currentPage().getUrl() is used to give the information after the HOST URL.
Sample Code:
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
Current URL is {!currentURL}
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class Sample {
public String currentURL {get;set;}
public Sample() {
currentURL = ApexPages.currentPage().getUrl();
}
}
Output:
Cheers!!!
Sample Code:
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
Current URL is {!currentURL}
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class Sample {
public String currentURL {get;set;}
public Sample() {
currentURL = ApexPages.currentPage().getUrl();
}
}
Output:
Cheers!!!
FieldSetMember Class
Use the methods in the Schema.FieldSetMember class to get details about fields contained within a field set, such as the field label, type, a dynamic SOQL-ready field path, and so on.
Check the below link for more information
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_FieldSetMember.htm
Cheers!!!
Check the below link for more information
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Schema_FieldSetMember.htm
Cheers!!!
September 7, 2016
What happens when we use with sharing in web service class?
Apex class methods that are exposed through the API with the webService keyword don't enforce object permissions and field-level security by default. We recommend that you make use of the appropriate object or field describe result methods to check the current user’s access level on the objects and fields that the webService method is accessing..
Also, sharing rules (record-level access) are enforced only when declaring a class with the with sharing keyword. This requirement applies to all Apex classes, including to classes that contain webService methods. To enforce sharing rules for webService methods, declare the class that contains these methods with the with sharing keyword.
Check the below link for more info
http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_web_services_methods_exposing.htm
Cheers!!!
Also, sharing rules (record-level access) are enforced only when declaring a class with the with sharing keyword. This requirement applies to all Apex classes, including to classes that contain webService methods. To enforce sharing rules for webService methods, declare the class that contains these methods with the with sharing keyword.
Check the below link for more info
http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_web_services_methods_exposing.htm
Cheers!!!
Contact Hierarchy in Salesforce
Salesforce.com creates an organization chart based on the contacts selected in the Reports To field of each contact. To create a single chart for an account, make sure every contact but the one at the top of the hierarchy contains another contact in the Reports To field.
1. Open any contact.
2. Click "View Org Chart" in Contact.
3. Contact Hierarchy opens.
Cheers!!!
1. Open any contact.
2. Click "View Org Chart" in Contact.
3. Contact Hierarchy opens.
Cheers!!!
How to call getter method in Salesforce test class?
Sample Code:
public List < SelectOption > exampleProperty {
get {
//Do something;
}
}
Test Class code:
List < SelectOption > tempOptions = obj.exampleProperty;
Cheers!!!
public List < SelectOption > exampleProperty {
get {
//Do something;
}
}
Test Class code:
List < SelectOption > tempOptions = obj.exampleProperty;
Cheers!!!
How to display error message next to field in Visualforce page in Salesforce?
Sample Code:
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!newAcct.Name}"/>
<apex:inputField value="{!newAcct.Industry}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Store" action="{!insertAcct}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public with sharing class Sample {
public Account newAcct {get;set;}
public Sample() {
newAcct = new Account();
}
public PageReference insertAcct() {
if ( newAcct.Industry == null ) {
newAcct.Industry.addError('Please fill Industry');
return null;
} else {
insert newAcct;
PageReference pg = new PageReference('/' + newAcct.Id);
pg.setRedirect(true);
return pg;
}
}
}
Output:
Cheers!!!
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!newAcct.Name}"/>
<apex:inputField value="{!newAcct.Industry}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Store" action="{!insertAcct}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller:
public with sharing class Sample {
public Account newAcct {get;set;}
public Sample() {
newAcct = new Account();
}
public PageReference insertAcct() {
if ( newAcct.Industry == null ) {
newAcct.Industry.addError('Please fill Industry');
return null;
} else {
insert newAcct;
PageReference pg = new PageReference('/' + newAcct.Id);
pg.setRedirect(true);
return pg;
}
}
}
Output:
Cheers!!!
Subscribe to:
Posts (Atom)