For Salesforce CRM online Training please contact :+91 9964773322 or +91 9393934143. Website : https://www.salesforcestart.com/
Tuesday, 11 April 2017
Friday, 7 April 2017
How to Test Salesforce REST API
How to Test Salesforce REST
API
To Test
Salesforce Rest API First we need to create Connected App in Salesforce.Once we
created Connected App it will generate consumer or client id and consumer
secret.
After that
we need to create Access-token using below steps.
1.grant_type=password&client_id=YourClientId&client_secret=YourClientSecret&username=YourUserName&password=YourPassword+securitytoken
EX:
client_id
=
3MVG9ZL0ppGP5UrB.7GK_luxRT7StxC8dM37EZzuyrj0LMr_TaiMZatpDKASHUikAvgczZCo1ONfmzhV5LER1
client_secret
= 1328342625760846904
username = username
password=YourPassword+securitytoken
Content-Type
: application/x-www-form-urlencoded
Here we will
get response like below format:
{"access_token": "00D28000001xtTR!AQkAQO.ZKKI4ccUpsQLzm.RpgI4HxLuMU8vqrpmpku_DEc3_aHMs9ar60o_l2HR9Vc2cF3IbFS8jC5UDD38h3CmXvBX6ue42","instance_url": "https://ap2.salesforce.com","id": "https://login.salesforce.com/id/00D28000001xtTREAY/00528000005dGo3AAE","token_type": "Bearer","issued_at": "1491551856783","signature": "RxPY7+SXQEyaIzTW3B5c1N/0C3ciwhojKNbULX9Xawo="}
Now we will
test Rest WS using above access token.
Sample
RestClass:
@RestResource(urlmapping
= '/showAccounts/*')
global class
RestExample {
@HttpGet
global static list<account>
getAccounts(){
list<account> lstAccounts = new
list<account>();
RestRequest request =
RestContext.request;
system.debug('request >>>' +
request);
string accName =
request.params.get('name');
system.debug('==accName==='+accName);
lstAccounts = [select id,name,phone
from account where name =: accName];
system.debug('===result==='+lstAccounts);
return lstAccounts;
}
}
Using Below
Extensions also we can test REST WSs.
Advanced REST client -
Chrome Web Store
Postman - Chrome Web
Store
Tuesday, 4 April 2017
Sample Comments for classes and methods.
Class Comments:
/*********************************************************************************
Class Name: SampleClass
Purpose: 1. This is the class for creating data.
Please maintain only the last 5 history changes/modifications in the audit log
History of Changes:
--------------------------------------------------------------------------------------------------------------------------
Date Developer Comments
--------------------------------------------------------------------------------------------------------------------------
07-Feb-2017 Developer Name Added new method
********************************************************************************/
public class SampleClass{
Method Comments:
/*
* MethodName : sampleMethod
* Description : searching all accounts data based on name.
*/
public static void sampleMethod(){
}
}
/*********************************************************************************
Class Name: SampleClass
Purpose: 1. This is the class for creating data.
Please maintain only the last 5 history changes/modifications in the audit log
History of Changes:
--------------------------------------------------------------------------------------------------------------------------
Date Developer Comments
--------------------------------------------------------------------------------------------------------------------------
07-Feb-2017 Developer Name Added new method
********************************************************************************/
public class SampleClass{
Method Comments:
/*
* MethodName : sampleMethod
* Description : searching all accounts data based on name.
*/
public static void sampleMethod(){
}
}
Saturday, 28 January 2017
How to disable/enable all validation rules for data loading in Salesforce
How to disable/enable all validation rules for data loading in Salesforce:
1) click Setup, then on the left side, click Develop/Custom Settings.
2) click New and create your settings as hierarchy/public

1) click Setup, then on the left side, click Develop/Custom Settings.
2) click New and create your settings as hierarchy/public

3) now create a custom field of type Checkbox: click New, select Checkbox, click Next, type the name of the field as “Disable Validation Rules”, default to Unchecked, click Next, then click Save.
4) in the Custom Setting Definition/Your App Settings screen, click Manage to start configuring the setting you just created.
5) click the New button above “Default Organization Level Value”, leave the checkbox “Disable Validation Rules” unchecked and then click Save.
6) click “Back to List”, click the New button at the bottom, select Profile or User then choose the user id or profile that will perform the data loading, then click “Disable Validation Rules” and click Save.
7) now edit the validation rule appending the expression (highlighted below)
&& NOT( $Setup.Your_App_Settings__c.Disable_Validation_Rules__c )
&& NOT( $Setup.Your_App_Settings__c.Disable_Validation_Rules__c )

8 ) click Save
9) now the validation rule will only apply if the setting checkbox
Disable Validation Rules is unchecked for your profile/user
Disable Validation Rules is unchecked for your profile/user
10) you can now load data freely and then, later, re-enable all
validation rules for your profile/user by changing the custom
setting.
validation rules for your profile/user by changing the custom
setting.
11) you can use this way of implementing Custom Settings on
triggers too, just use the syntax below:
triggers too, just use the syntax below:
- Your_App_Settings__c s = Your_App_Settings__c.getInstance( UserInfo.getUserID() );
- if( s.Disable_Validation_Rules__c ) return;
Examples :
In Trigger :
trigger AccountTriggerHandler on Account (before insert,before update,after update) {
Application__c bypassTrigger= Application__c.getInstance( UserInfo.getUserID() );
if(!bypassTrigger.DisableValidations__c){
if(trigger.isbefore && trigger.isinsert){
for(account acc : trigger.new){
if(acc.phone == null){
acc.phone.addError('phone no required');
}
}
}
}
}
Validation :
ISBLANK( Phone ) && NOT( Setup.Application__c.DisableValidations__c )
Sunday, 18 December 2016
Salesforce Advanced Interview Questions
Salesforce Advanced Interview Questions
1.write sample trigger to update Account phone on its related contacts.
TriggerName: AccountHandlerTrigger
trigger AccountTriggerHandler on Account (after update) {
AccountHandlerClass.updateContacts2(Trigger.newMap);
}
/*******************************************************************
Class Name: AccountHandlerClass
Purpose: 1. This is the Trigger Handler class for Account object
public class AccountHandlerClass {
/******* Sample method 1 *********/
public static void updateContacts2(map<id,account> newAccountMap){
list<contact> lstCons =[select id,name,phone,Accountid from contact where Accountid in :newAccountMap.keySet()];
system.debug('lstCons :'+lstCons);
list<contact> updCons = new list<contact>();
if(!lstCons.isEmpty()){
for(contact c : lstCons){
if(c.Phone != newAccountMap.get(c.AccountId).phone){
c.Phone = newAccountMap.get(c.AccountId).phone;
updCons.add(c);
}
}
}
update updCons;
}
2.write Soql query to Accounts with contact.
list<account> acc = [select Id,name from Account where Id In (select AccountId from Contact)];
system.debug('acc : '+acc.size());
3.if a controller has a series of extensions then which extension will execute first.
If both extension having same method, whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list will execute first.
====================================================================
<apex:page standardController="Account" extensions="Extension1,Extension2">
<apex:form>
Displaying name from Extensions : "{!Name}"
</apex:form>
</apex:page>
====================================================================
public class Extension1 {
public Extension1(ApexPages.StandardController controller){}
public static string getName(){
return 'Prasad';
}
}
public class Extension2 {
public Extension2(ApexPages.StandardController controller){}
public static string getName(){
return 'Kalyan';
}
}
=======================================================================
4.Transaction Control using SavePoint and Rollback in Salesforce.
SavePoint and Rollback will help us to maintain transaction for DML statement.
Suppose you have written multiple lines of DML statements in a try block, If any error occurs during DML Operations, the operation will be rolled back to the most recent save point and the entire transaction will not be aborted.
Savepoint sp;
try{
sp = Database.setSavepoint();
Account a = new Account();
a.Name = 'Test Account';
insert a;
Contact c = new Contact(Account = a.Id);
c.FirstName = 'Biswajeet';
c.LastName = 'Samal';
insert c;
}
catch(Exception e){
Database.RollBack(sp);
}
More Info :
5.can we do a Callout from with in a Trigger ?
6.How to get Custom Settings in Apex Test code?
@isTest
public class BIIB_testClassHelper{
/*
* Creating custom settings data in creation in test class .
* Avoid @isTest(SeeAllData = True) in test classes..
*/
public static testMethod void customsettingcreation(){
Id SampleRecordtypeID=Schema.SObjectType.Case.getRecordtypeinfosbyname().get('Recordtype Name').getRecordtypeId();
string Country = 'USA';
Custom_Settings__c cusutomsetting = new Custom_Settings__c();
cusutomsetting.RecordType_ID__c=SampleRecordtypeID;
cusutomsetting.CountryName__c=Country;
insert cusutomsetting;
}
}
7.Approve/Reject many Records Through Apex.
http://salesforce.stackexchange.com/questions/119905/approve-reject-many-records-at-once-via-apex
8.Trigger to update All contact names in Account Field.
===================================================================
trigger ContactTrigger_Handler on Contact (after insert,after delete) {
if(trigger.isinsert && trigger.isAfter){
updaetcontactnamefield.updateaccount(Trigger.new);
}
if(trigger.isdelete && trigger.isAfter){
updaetcontactnamefield.updateaccount(Trigger.old);
}
}
====================================================================
public class updaetcontactnamefield{
public static void updateaccount(list<contact> contacts){
set<id> accountIds = new set<id>();
if(!contacts.isEmpty()){
for(contact c:contacts){
accountIds.add(c.accountid);
}
}
list<account> lstAcc = new list<account>();
for(Account acc : [Select id, name, description,
(Select Id, name, LastName From Contacts)
From Account Where Id In : accountIds])
{
List<String> lstSrting = new List<String>();
for(Contact con : acc.contacts)
{
lstSrting.add(con.lastname);
}
acc.description = String.join(lstSrting, ',');
lstAcc.add(acc);
}
update lstAcc;
}
}
====================================================================
9.How to setup Field Level Security (FLS) for Person Account Fields.
ORWhy I am not able to find list of Person Account fields in Field Level Security (FLS) settings when navigated to fields on Account Object.
Ans :
Field
Level Security (FLS) of Person Account fields ar controlled by Contact Fields.
So, if you want to setup FLS of Person Account Fields navigate to fields of
Contact and it will be reflected on Person Account.
10.In below code snippet , What is your observation and what is going wrong ?
trigger TestBeforeDelete on Lead (before Delete) {
for(Lead l : Trigger.Old)
{
l.addError('error');
}
String msgBody = 'Test Email';
String Subject = 'Test from Cogni Force on Lead';
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'abc@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('abc@gmail.com');
mail.setSenderDisplayName('Cogniforce Test Simulator');
mail.setSubject(Subject);
mail.setPlainTextBody(msgBody);
mail.setHTMLBody(msgBody);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
Ans :
It will not send any email. Because “adderror” prevents all transactions from committing including emails.
10.How To Start Loading Data From 101 Row Of The CSV File In Data Loader?
In Dataloader Settings we need to specify Start Row no:
11.Calling future method from batch class?
Future method cant be called from future or Batch.
10.How To Start Loading Data From 101 Row Of The CSV File In Data Loader?
In Dataloader Settings we need to specify Start Row no:
11.Calling future method from batch class?
Future method cant be called from future or Batch.
recommend the use of System.Queueable call instead of @Future. You can create a class that is constructed with any kind of argument that you want to hand in, like so:
public class DeferredHandler implements System.Queueable{
public void execute(System.QueueableContext objContext) {
//do your @Future stuff here
}
}
And invoke him from inside your batch like this:
//defer stuff
System.Queueable job = new DeferredHandler(key2val);
System.enqueueJob(job);
12.How we can display serial-nos in standardlistcontroller.
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
<apex:pageBlock >
<apex:variable var="rowcount" value="{!0}" />
<apex:pageBlockTable value="{!accounts}" var="a" >
<apex:column>
{!rowcount} <apex:variable var="rowcount" value="{!rowcount+1}" />
</apex:column>
<apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
12.How we can display serial-nos in standardlistcontroller.
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
<apex:pageBlock >
<apex:variable var="rowcount" value="{!0}" />
<apex:pageBlockTable value="{!accounts}" var="a" >
<apex:column>
{!rowcount} <apex:variable var="rowcount" value="{!rowcount+1}" />
</apex:column>
<apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Monday, 5 December 2016
Salesforce Winter17 Developer Maintenance (401)
1.Which
capability does the Lightning Mass Action feature allow beyond standard
Actions?
A.
Firing a single action on multiple objects at once.
B. Firing multiple actions on multiple objects at once.
C. Firing a single action on multiple records at once.
D. Firing multiple actions on multiple records at once.
B. Firing multiple actions on multiple objects at once.
C. Firing a single action on multiple records at once.
D. Firing multiple actions on multiple records at once.
2.What
does the new ISCLONE function check when comparing two items?
A.
If an item has the ability to be cloned.
B. If an item was cloned when created.
C. If one Item is a clone of another.
D. If an Item has ever been cloned.
B. If an item was cloned when created.
C. If one Item is a clone of another.
D. If an Item has ever been cloned.
3.Where
is the exported template saved in an Org when using Lightning Bolt for
Communities?
A.
Community Brand Manager
B. Community Creation wizard
C. Installed Packages
D. Personal App Exchange
B. Community Creation wizard
C. Installed Packages
D. Personal App Exchange
4.What
must be shared between two objects to invoke one process from another using
Process Builder?
A.
Owner
B. Master-Detail
C. Junction Object
D. Unique ID
B. Master-Detail
C. Junction Object
D. Unique ID
5.Which
two pieces of information should be recorded on the Work Type object?
Choose 2 answers
Choose 2 answers
A.
The estimated complexity of a Task.
B. The skills recommended to complete a Task.
C. The list of activities to complete a Task.
D. The estimated duration of a Task.
E. The needed equipment to complete a Task
B. The skills recommended to complete a Task.
C. The list of activities to complete a Task.
D. The estimated duration of a Task.
E. The needed equipment to complete a Task
Salesforce Winter17 Administrator Maintenance (201)
1.Universal
Containers’ sales reps use the Lightning Experience. They need to send quotes
to their prospects. How can this be accomplished?
A.
Create a quote from the product and email as a link.
B. Create a quote from the opportunity and email as a link.
C. Create a quote from the opportunity and email as a PDF.
D. Create a quote from the lead and email as a PDF.
B. Create a quote from the opportunity and email as a link.
C. Create a quote from the opportunity and email as a PDF.
D. Create a quote from the lead and email as a PDF.
2.Which
three Chatter Feed functionalities are available in the lightning experience?
Choose 3 answers
Choose 3 answers
A.
Chatter comments automatically post without refresh.
B. Videos play directly in the Chatter feed.
C. Users can edit Chatter feed posts and comments.
D. Chatter Instant Messages without refresh.
E. Users can launch a Chatter Meeting directly from the feed.
B. Videos play directly in the Chatter feed.
C. Users can edit Chatter feed posts and comments.
D. Chatter Instant Messages without refresh.
E. Users can launch a Chatter Meeting directly from the feed.
3.Which
two features are available in Partner Communities using the Customer Service
template?
Choose 2 answers
Choose 2 answers
A.
Users can create their own list views.
B. Field level help displays to the user.
C. Report charts can be added to the layout.
D. Sales Path available for opportunities only.
B. Field level help displays to the user.
C. Report charts can be added to the layout.
D. Sales Path available for opportunities only.
4.The VP of Marketing at Universal Containers would like to track which campaigns led to opportunities. They would like to evenly attribute revenue across all campaigns that touched the opportunities. Which two tools should the administrator configure to meet the VP’s request?
Choose 2 answers
A.
Create a custom campaign influence attribution model.
B. Add the Campaign Results section to the opportunity page layout and assign users the campaign influence permission so they can edit the fields.
C. Add the Influenced Opportunities related list to the campaign page layout and add the Campaign Influence to the opportunity page layout.
D. Clone the standard campaign influence model into a custom model.
E. Add the Influenced Opportunities related list to the opportunity page layout and add the Campaign Influence to the campaign page layout.
B. Add the Campaign Results section to the opportunity page layout and assign users the campaign influence permission so they can edit the fields.
C. Add the Influenced Opportunities related list to the campaign page layout and add the Campaign Influence to the opportunity page layout.
D. Clone the standard campaign influence model into a custom model.
E. Add the Influenced Opportunities related list to the opportunity page layout and add the Campaign Influence to the campaign page layout.
5.The sales manager at Universal Containers would like a dashboard component to list sales reps by opportunity pipeline amount with high and low values highlighted in different colors. With the Lightning Experience enabled, how should the system administrator configure the component to meet the sales manager’s need?
A.
Create a metric component for each rep in descending order with conditional
highlighting in Lightning.
B. Create a table component, conditional highlighting and sort the columns within Lightning.
C. Create a table component and sort the columns in Lightning. Add conditional highlighting in classic.
D. Create a table component, conditional highlighting in Lightning and sort the columns in classic.
B. Create a table component, conditional highlighting and sort the columns within Lightning.
C. Create a table component and sort the columns in Lightning. Add conditional highlighting in classic.
D. Create a table component, conditional highlighting in Lightning and sort the columns in classic.
Subscribe to:
Posts (Atom)
Complete Salesforce CPQ training Free videos
Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...
-
Salesforce advanced admin certification dumps More Videos: Salesforce advanced admin certification dumps
-
Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...
-
Triggers Trigger: Apex can be invoked through the use of triggers . A trigger is Apex code that executes before or after the f...











