SFDC Scenario Based Iquestions
SFDC Scenario Based Iquestions
Questions
I have a profile by name ‘ProvideReadAccess’ and two users U1 and U2 assigned to it. And I
have object X.
My Question is I want to have ReadWrite access for U1 and ReadOnly access for U2 for the
object X.
How do I do this?
Answer:
Read Access for both users is common hence in the Profile settings give ‘Read’ access for the
object ‘X’
By doing this User U2 will be able to read all the records( One condition satisfied) but U1 will
also be able to only read the records(Second condition not satisfied).
So next what do we do is we create a permission set say ‘GrantWriteAccess’ and in this
permission set we give the object ‘X’ the Write access and assign the user U1 to this permission
set.(2nd condition satisfied).
I have not given any CRUD permission in the profile ‘P1’ for an object O1, yet I’m able to create
records for object ‘O1’. How could this be possible?
Answer:
3)Consider a scenario
I have two objects Obj1 and Obj2 which are not related to each other.Now I want to create a
Master Detail Relationship(MDR) between these objects How can I do this?
Answer:
First choose which object has to be a Parent object(Master) and Child Object(Detail).
For our understanding lets say for now we decide Obj1 to be Master object and Obj2 to Detail
object.
First lets under stand what’s a Master Detail relation ? Every child should have a parent.
Which means every record in Obj2 should have a related parent record in Obj1. Also One
child can have only one parent. But One parent can have multiple children.
Scenario 1: if there are pre existing records in the Obj2 then?
With the above understanding on Master Detail relation we have to be sure that every record in
Obj2 has a related record in Obj1.
And in our scenario Obj1 and Obj2 are not related to each other. So first we have to create a
basic Look up relation between these two objects so that we can establish a relation between
these two objects.
2. Update the Lookup field of all the records in Obj2 with a value from the Obj1 (Related field)
4)Consider a scenario
I’m trying to implement Pagination. Initially i want to display 50 records and when user click on
Next button, the records stating from 51 to 100 should get displayed. How do I accomplish this.
Answer:
The key question here is how do we fetch next 50 records when user clicks on ‘Next’?
One possible way to implement this is to have ‘OFFSet’ used in SOQL which fetches the
records.
5) Consider a scenario
Answer:
I have a User, Who will leave the organization tomorrow. He is basically a manager and there
are 15 users below him.
Now when this user leaves the organization I would generally inactivate the User.
But now my concern is if I inactivate this user What happens to the Role hierarchy? the
assignment rules, Approval processes, the records created by him and records to which he is
the default owner like leads and cases.
what would be best possible solution to keep this application intact and running and yet have
this user deactivated?
Answer:
To prevent users from logging into your organization while you perform the steps to deactivate
them, you can freeze user accounts.
So in this way until you find ways to remove this User from Role hierarchy/assignment
rules/update the Owner of the records created by him / from any place where this user is used,
we can make use of FREEZE button on the user record.
Note:
1. When we click on FREEZE button, the user will not be able to login to the application any
more.
2. Freezing user accounts doesn’t frees the user licenses available for use in your organization.
We have to de activate the user to free the license.
I want to delete 20000 records and I don’t want them to be recovered from recycle bin.
OR
I want to do a mass delete on set of records and don’t what them getting into recycle bin.
What possible options do I have?
Answer:
Let say I have a page which displays the set of records from Account object and I’m using a
standard controller.
Now I have two users belonging to same Profile. When they login and view this page, they get a
message “Insufficient privileges”.
What could be the reason for this? Or who would u arrive at a solution?
Answer :
Notice below points:
Question speaks about standard Object and Standard Controller.
Also remember permission to a object is given by Profile.
So we need to check if the user has permission to read data of this Object.
Only if the permission is given to the user,he’ll be able at access them else he will get an error
message as “Insufficient privileges”
Answer:
==>Object data might change between the time you call the future method and the time it actually
executes.So,we pass record id.
2)IF downtime occurs and future method was running what will happen?
==>The Future method execution will be rolled back and will restart after downtime overs.
3)IF the future method was queued before a service maintenance what will happen?
==>It will remains in queue and when maintenance is over and resources are available it will get
execute.
4) If the batch is executed without the optional scope parameter and If in batch apex suppose we
have 600 jobs and there are total 200 records to be proceeds in each transaction,so in total we
have 3 transaction.If first transaction succeeds but second fails so in this case the records
update done in first transaction are rolled back or not?
suppose we have 600 jobs and there are total 200 records to be proceeds in each transaction,so if we want to
count records as batch proceeds maintaining state is important as after 200 set of records new transaction will
start and members will loose their values. By implementing
Database.Stateful we can maintain state after transaction is over and can store previous values.
Syntax:
7)With the before Insert event which context variable is correct Trigger.new or
Trigger.newmap?
Trigger.newmap will not be supported as we do not have id of record before the record is inserted.
8)What will you do if a method inside apex class need to be executed only when it is getting
called from trigger?
We will use trigger.isexecuting in apex class to check if the method inside apex class is getting called from
trigger and will execute the method if getting called from trigger.
9)What will happen if you forgot to store remote site url in remote site setting?
The total number of records that can be queried by soql queries is 50,000 record. If we query more than 50,000
record we exceeds the heap limit.
To avoid this we should use SOQL query for loop it can process multiple batches of record using call to query
and query more.
}
//A runtime exception is thrown if the below query returns enough records to exceed your heap limit.
Yes it is possible to call a batch class from trigger but in case of call to apex callout method the method needs to
be asynchronous.
It might happen that the test class pass in sandbox but fails in production if we do not have the same record in
production.
13) If we are using @testSetup in test class and let say we have two test methods in the same test
class which are using the data from @testSetup and performing operations on data, so in this let
say if i am updating data from @testSetup in first test method and also using the data
from @testSetup in second test method whether i will get the fresh data or the updated data in
second test method.
operation done on the records from @testSetup are local to the test method only, so i will get fresh data in
second test method as well.
Sample example:
@isTest
Public class testclass
{
@testSetup
static void testsettingup()
{
contact obj=new contact();
obj.firstname='test';
obj.lastname='data';
insert obj;
}
static testmethod void testmethodname() //No parameter inside test method
{
test.starttest();
contact obj1=new contact();
obj1=[Select id,firstname from contact where firstname='test'];
obj1.firstname='test1';
update obj1;
// operation done on the records from @testSetup are local to this test method only.
test.stoptest();
}
}
14) How many times a test method can call test.starttest() and test.stoptest()?
Each test method can call start test and stop test only once, but number depends on the number of test methods
in test class.
15) What will happen if a class is not declared with "With sharing" or "Without sharing" and it
get called from another class which is declared with "With sharing"?
If we do not declare class with "With sharing" or "Without sharing" the class will not take into account the
sharing rules but if this class is called from another class which is declared with "With sharing" it will take into
account the sharing rules.
16) IF the class with "With sharing" is calling method of another class with "Without sharing"
what will happen?
IF the class with "With sharing" is calling method of another class with "Without sharing" than the method
inside "Without sharing" class will execute without sharing rules.
17) IF the class with "Without sharing" is calling method of another class with "With sharing"
what will happen?
IF the class with "Without sharing" is calling method of another class with "With sharing" than the method
inside "With sharing" class will execute with sharing rules.
18)Let say user do not have permission on a child object and he is having permission on parent
object to read/create/edit/delete parent object,If I create a trigger on parent object to insert a
child record after parent record is created,will it create a child record or not after user insert
parent record manually?
It will create a child record.(With sharing keyword has nothing to do with user permissions).
We must deploy My Domain in our org if you want to use Lightning components otherwise we would not be
able to see the output of lightning components.
21) What are the different type of pages we can create using lightning component and what are
the
different types of component supported in lightning pages?
1)App Page
2)Home Page
3)Record Page
2) Custom Components:
On AppExchange we can find packages containing components that are ready to use in lightning app builder.
22) What are required parameter while declaring attribute in lightning component?
Name and type are parameter of attribute which are always required in attributes,description is another
parameter where we can mentioned about description of attribute.Description is not an required attribute.
Similarly we have default parameter to give some default value to attribute.To set the access for an attribute we
have access parameter where we can specify about public,private,global access for an attribute.By default the
attribute have public access.
23) Which type of attribute we can use in lightning component to store fractional values?
Doubletype.
Decimal is better than Double for maintaining precision for floating-point calculations.
It’s preferable for currency fields.
25) Let say we are storing some default values in map attribute.
26) To form a container around a information related to single item or group of item what we
need to use in lightning component?
Lightning:card.
27) How to obtain the id of the current record in lightning component?
By using force:hasRecordId interface in lightning component we can assigned the id of the current record to
lightning component. This interface adds an attribute named "recordId" to the component. The type of
attribute is string and has 18-character Salesforce record ID.
28) you are asked to override the standard action using lightning component how you will
achieve this?
29) Which interface you will implement in lightning component if you want your component
to be available only for record detail page?
Interface flexipage:availableForRecordHome make the component available for record pages only.
30) you are asked to create a component for some requirement and create a tab for the same
in lightning experience what you will do to achieve this?
Interface force:appHostable in component allow it to be used as a custom tab in Lightning Experience or the
Salesforce mobile app.
31) On load of lightning component you are required to execute some action what you will do
to achieve this?
We will use "Init" Event which is also called as the constructor of lightning component.The init event is called
once the component construction is over.
Basic Syntax:
32) you are asked to execute some action when value change is detected in one of the attribute
what will you do?
The change event is called when the value in one of the attribute changes.
As an Example If i am having attribute " Anyname", on change of attribute "Anyname" if i want to call
javascript method i can do this as:
Syntax:
33) You are having a requirement to pass value from child component to parent component
which type of event you will use?
We will use Component event. Component event are used in case when there is a relationship between
component. Component Events are fired by the child components and handled by the parent component.
34) You are having a requirement to pass value from one component to other component which
are not related but a part of same application which type of event you will use?
We will make use of Application event. Application event are the event handle by any component no matter
what relationship between them but they should
be inside single application.
35) Explain the event propagation rule for application event and component event?
36) You are calling child component from Parent component and passing one of the attribute
value from Parent component to child component attribute while calling child. What will you do
if you want to binding both parent and child component attribute?
I will make use of bound expression,
AttributeNameFromChild="{!v.AttributeNameFromParent}" is a bound expression. Any change to the value of
the childAttributeName attribute in child component also changes the value of parentAttributeName attribute
in parent component and vice versa.
<aura:component>
<c:ChildComp childAttributeName="{!v.parentAttributeName}" />
</aura:component>
37) You are calling child component from Parent component and passing one of the attribute
value from Parent component to child component
attribute while calling child. What will you do if you do not want to bind parent and child
component attribute?
I will make use of unbound expression,
AttributeNameFromChild="{#v.AttributeNameFromParent}" is a Unbound expression. Any change to the
value of the childAttributeName attribute in child component has no effect on the value of
parentAttributeName attribute in parent component and vice versa.
<aura:component>
<c:ChildComp childAttributeName="{#v.parentAttributeName}" />
</aura:component>
38) You are in a need of passing a value from Parent component controller to Child
component controller what will you do?
We will make use of Aura:method.
39) How to ensure field level security while working with lightning components?
It is a component based framework. It is an event driven architecture. It can called as a MVCC framework
which has two controller, one is client side and other is server side.
Make a tab for lightning component and include this tab in Salesforce1 mobile navigation.
43) What are the requirement to call a server side controller method from Javascript
controller?
44) We have a requirement to create account using new button and default some values in the
new account screen how we can achieve this requirement?
We can make use of force:createRecord, force:createRecord is an event that opens a page to create a record for
specific entity.
Sample syntax:
defaultFieldValues attribute inside setParams let us auto populate value on fields inside record form.
COMPONENT:
<aura:component implements="flexipage:availableForAllPageTypes">
<lightning:button label="New Account" onclick="{!c.createAccount}"/>
</aura:component>
CONTROLLER:
({
createAccount : function(component, event, helper) {
var recordEvent=$A.get("e.force:createRecord");
recordEvent.setParams({
"entityApiName": "Account",
"defaultFieldValues":{
"Industry":"Apparel"
}
});
recordEvent.fire();
}
})
Sample syntax:
<force:recordData aura:id="someId"
recordId="{!v.recordId}"
layoutType="{!v.layout}"
fields="{!v.fieldsToQuery}"
mode="VIEW"
targetRecord="{!v.record}"
targetFields="{!v.simpleRecord}"
targetError="{!v.error}"
/>
For every force:recordData component referencing the updated record, LDS does two things.
LDS notifies all other instances of force:recordData of the change by firing the recordUpdated event with the
appropriate changeType and changedFields value.
It sets the targetRecord and targetFields attribute on each force:recordData to the new record value. If
targetRecord or targetFields is referenced by any UI, this automatically triggers a rerender so that the UI
displays the latest data.
Note: If force:recordData is in EDIT mode, targetRecord and targetFields are not automatically updated.
Cognizant Interview Questions
Technical Round-1 and Round-2
1. Difference between all evaluations criteria in workflow rules?
Ans-
Evaluate the rule criteria each time a record is created. If the rule
criteria is met.
created In this option, the rule never runs more than once per record.
2. We have two team service team and sales team, and we have 15 fields in Account object
and want to show 10 fields to service team and 5 fields to sales team, how will you do
this?
3. Define all sharing rules?
4. What is Re-evaluate checkbox in workflow?
5. What is trigger framework?
6. What is process builder? Can we use apex class in process builder?
Ans:- In Salesforce.com, for Activity objects (Task & Event), there are only 2 option in the Organization-
Wide Defaults sharing setting:
Controlled by Parent
- Private
Private
Only activity owner (label as Assigned To), and users above the activity owner in the role hierarchy
can edit and delete the activity.
Users with read access to the record to which the activity is associated (Name and Related To) can view
and report on the activity.
Controlled by Parent
A user can perform an action (such as view, edit, transfer, and delete) on an activity based on whether
he or she can perform that same action on the records associated with the activity.
Example, if a task is associated with the Acme account and John Smith contact, then a user can only
edit that task if he or she can also edit the Acme account and the John Smith record.
13. Difference between save report and run report?
14. What are the buckets and formula fields in reports?
15. What is future method? What are the restriction of the future method? Can we call future
method from batch class?
16. Write query to get child from parent.
17. Assume there is user lookup in Account, if any user create account record then that user Id
should populate in lookup, how will you do this task?
18. Can we update record on account on ‘After insert’ trigger event?
19. What is forecasting in Salesforce?
20. What is territorial management?
21. What are the types of trigger and events?
Ans-
There are two types of triggers:
Before triggers are used to update or validate record values before they’re saved to the database.
After triggers are used to access field values that are set by the system (such as a record's Id or
LastModifiedDate field)
Trigger Events:
Before Insert, Before Update, Before Delete, After Insert, After Update, After Delete and after undelete
22. What is workflow and time dependent workflow? Write will send mail after 15 mins?
23. Create visual force page1 with 3 rows data like Here no data from database, just you create your
own field
A) Column: Name Checkbox
Row 1: Arun True
Row 2: B False
Row 3: C True
Now we have showData button, then on click on button data which has checkbox
True should display on another visual force page.