Salesforce Scenario Based Interview Questions and Answers | Part 3

Force Fellow
6 Feb 202320:08

Summary

TLDRThis video explores advanced Salesforce interview questions, focusing on Apex, asynchronous Apex, and Lightning Web Components (LWC). It delves into Salesforce's request pipeline, discussing the execution order of automation tools and the impact of validation and workflow rules. The presenter also addresses the use of platform events for handling asynchronous operations in LWC, the application of user permissions in Apex, and the intricacies of DML operations across multiple objects. Additionally, the video covers the differences between 'with sharing' and programmatic sharing in Apex, the behavior of queueable jobs, and lead conversion ownership. The script aims to prepare viewers for technical Salesforce interviews by covering these complex topics.

Takeaways

  • πŸ˜€ Salesforce interviews often ask scenario-based questions involving Apex, asynchronous Apex, admin, Integrations in LWC, and other Salesforce tools.
  • πŸŽ₯ The speaker has created a series of videos covering LWC from basic to advanced topics, with links provided in the description for further learning.
  • πŸ”„ The order of execution for Salesforce automation tools is governed by the 'wave of execution', where validation rules execute before workflow rules.
  • 🚫 A validation rule conflict scenario reveals that a record might not be saved due to validation rule conditions, highlighting the importance of rule design.
  • πŸ”„ Custom validation rules do not rerun if a field update is made by a workflow rule, which is considered a loophole in the Salesforce execution pipeline.
  • πŸ“‘ Future methods in Apex, being asynchronous, cannot directly show callout responses in LWC components, but can be achieved using platform events and the Lightning Message Service.
  • πŸ”‘ Understanding Salesforce security and sharing models is crucial, as demonstrated by the scenario involving object permissions and DML operations in triggers.
  • πŸ”„ Apex code typically runs in 'system mode', bypassing user permissions, but Salesforce provides ways to enforce 'user mode' for respecting permissions during DML operations.
  • πŸ” The difference between 'with sharing' and Apex 'manage sharing' settings is explained, with the former enforcing sharing rules and the latter allowing programmatic sharing of records.
  • ❌ If a transaction rolls back after submitting a queueable job, the job will not be processed, emphasizing the relationship between transactions and asynchronous jobs.
  • πŸ”„ Lead conversion in Salesforce changes the ownership of the Opportunity, Account, and Contact records to the user who performs the conversion, not the original lead owner.

Q & A

  • What is the order of execution for automation tools in Salesforce?

    -In Salesforce, the order of execution is predefined and known as the governor execution order. Validation rules execute prior to workflow rules, and custom validation rules do not run again if field updates are made by workflow rules.

  • Why are custom validation rules not re-executed after a workflow rule modifies a field?

    -Custom validation rules are not re-executed after a workflow rule modifies a field because Salesforce's governor execution order dictates that only triggers and standard validation rules run again if a field update is made by a workflow rule.

  • Can we show the response of a future method callout on a Lightning Web Component (LWC)?

    -Directly showing the response of a future method callout on an LWC is not possible because future methods are asynchronous and execute in a separate thread. However, using platform events to publish and subscribe to the callout response can achieve this.

  • How can we handle permissions when inserting a record from a trigger in Salesforce?

    -Salesforce triggers run in system mode by default, which means they bypass user permissions. To enforce user permissions, you can use Apex code with user mode settings, such as `Database.enforceUserMode` or by using schema methods or user mode database operations.

  • What is the difference between 'with sharing' and Apex 'manage sharing' settings?

    -'With sharing' is a keyword used in Apex classes to enforce sharing rules for specific classes, ensuring that queries respect the user's permissions. 'Manage sharing' in Apex allows for programmatic sharing of records, where you can insert sharing records to grant access to specific users.

  • What happens to a queued job if the submitting transaction is rolled back?

    -If the submitting transaction is rolled back, the queued job will not be processed, as Salesforce does not execute asynchronous jobs in such cases.

  • Who becomes the owner of the opportunity, account, and contact after a lead conversion?

    -After a lead conversion, the user who is converting the lead becomes the owner of the opportunity, account, and contact, regardless of the original lead owner.

  • Can we perform DML on multiple objects in a single DML operation in Salesforce?

    -Yes, you can perform DML on multiple objects in a single DML operation by using a generic sObject list and adding different object records to it. This is possible as long as there is no parent-child relationship between the objects.

  • How can we save related objects in a single transaction in Salesforce?

    -You can save related objects in a single transaction by using an external ID as a foreign key to create parent and child records in a single DML operation.

  • Can we set the calling order of wire methods in LWC?

    -Directly setting the calling order of wire methods in LWC is not possible, as they are called automatically by the framework. However, dependencies can be managed by passing reactive parameters to dependent wire methods, causing them to re-call when the parameter value changes.

Outlines

00:00

πŸ€– Salesforce Interview Q&A on Apex and Validation Rules

This paragraph discusses scenario-based interview questions for Salesforce roles, focusing on Apex, asynchronous Apex, and validation rules. The video script explains how Salesforce handles conflicting validation rules during record insertion and saving, emphasizing the order of execution for Salesforce automation tools. It clarifies that validation rules are executed before workflow rules, and how this can lead to unexpected outcomes, such as a record being saved with a blank 'website' field despite a validation rule requiring it to be non-blank. The paragraph also touches on the importance of understanding the order of execution in Salesforce's automation pipeline.

05:03

πŸ”’ Salesforce Security and DML Operations in Triggers

The second paragraph delves into Salesforce security models and DML operations within triggers. It examines a scenario where a user with permissions on Object A but not on Object B attempts to insert a record into Object B from a trigger on Object A. The explanation covers system and user modes in Apex execution, highlighting that triggers run in system mode by default, thus bypassing user permissions. The paragraph also explores Apex's ability to enforce user mode with specific code approaches, such as using schema methods or user mode database operations, and discusses the implications for record ownership and accessibility post-insertion.

10:04

πŸ“š Performing DML on Multiple Objects and Understanding Sharing Settings

This paragraph explores the capability to perform DML operations on multiple objects within a single statement in Salesforce, demonstrating how to insert records of different objects into a single DML statement. It also discusses the possibility of saving related objects in a single transaction using an external ID as a foreign key. The paragraph further explains the difference between 'with sharing' and Apex managed sharing settings, detailing how 'with sharing' enforces sharing rules within an Apex class, while managed sharing settings allow for programmatic sharing of records in Apex.

15:05

πŸ”„ Impact of Transaction Rollbacks on Queueable Jobs and Lead Conversion Ownership

The final paragraph addresses what happens to queueable jobs if the submitting transaction is rolled back in Salesforce, clarifying that such jobs will not be processed. It also discusses the ownership dynamics during the lead conversion process, explaining that the owner of the lead becomes the owner of the newly created opportunity, account, and contact records. Additionally, the paragraph touches on the topic of setting the calling order of wire methods in LWC components, suggesting the use of reactive parameters to manage dependencies between wire methods.

Mindmap

Keywords

πŸ’‘Salesforce

Salesforce is a cloud-based customer relationship management (CRM) service that provides businesses with a suite of tools and applications to manage their interactions with customers and potential customers. In the video, Salesforce is the platform where various automation tools, such as triggers and workflows, are discussed, emphasizing its role in managing the request pipeline and executing automation tools in a predefined order.

πŸ’‘Validation Rule

A validation rule in Salesforce is a condition that must be met before a record can be saved. It helps ensure data integrity by enforcing business logic. In the video, the script discusses a scenario involving validation rules on the Account object, where one rule makes the 'website' field required and another makes it blank, illustrating how these rules interact during the record-saving process.

πŸ’‘Asynchronous Apex

Asynchronous Apex in Salesforce refers to code that is executed in a separate thread from the main user request, allowing for long-running processes without affecting the user's experience. The video mentions asynchronous Apex in the context of future methods and how they can be used to perform callouts and publish platform events, which are then consumed by Lightning Web Components (LWC).

πŸ’‘Lightning Web Components (LWC)

Lightning Web Components are a modern framework for building user interfaces in Salesforce. They are web components that follow the standard web component specifications. The video discusses how to handle future method callouts and responses within LWC, as well as the use of platform events to communicate between asynchronous Apex and LWC.

πŸ’‘Platform Events

Platform Events in Salesforce are a publish-subscribe messaging framework that allows for real-time communication between different parts of a Salesforce implementation. The video explains how platform events can be used to communicate the result of a future method callout to an LWC, showcasing their role in asynchronous communication.

πŸ’‘Object-Specific Security

Object-Specific Security in Salesforce controls access to records at the object level based on the user's profile and role hierarchy. The script explores a scenario where a user has permission on one object but not another, and how this affects the ability to insert records from a trigger, highlighting the importance of understanding Salesforce's security model.

πŸ’‘System Mode vs. User Mode

In Salesforce Apex, system mode ignores user permissions, allowing code to perform operations as if it were executed by a user with full access. User mode, on the other hand, respects the permissions of the user executing the code. The video explains that triggers run in system mode by default but can be enforced to run in user mode using Apex code, which is crucial for understanding how DML operations are affected by permissions.

πŸ’‘DML Operation

DML (Data Manipulation Language) operations in Salesforce include insert, update, delete, and upsert, which are used to modify data in the database. The video discusses performing DML on multiple objects in a single operation and the importance of understanding DML governor limits to optimize data operations within Salesforce.

πŸ’‘With Sharing

The 'with sharing' keyword in Apex classes enforces the organization's sharing rules when executing SOQL queries. The video explains how 'with sharing' affects the results of queries within an Apex class, ensuring that only records that the user is permitted to see are returned, which is essential for maintaining data privacy and security.

πŸ’‘Apex Managed Sharing

Apex Managed Sharing is a feature in Salesforce that allows developers to programmatically share records with other users or roles. The video provides an example of how to use Apex Managed Sharing to share a custom object record with a specific user, demonstrating its use in scenarios where sharing rules are not sufficient.

πŸ’‘Queueable Job

A Queueable Job in Salesforce is a type of asynchronous Apex that can be used to perform tasks that take a long time to complete. The video discusses the behavior of Queueable Jobs in relation to transaction rollbacks, explaining that if the submitting transaction is rolled back, the Queueable Job will not be executed, which is important for understanding the reliability of asynchronous operations.

πŸ’‘Lead Conversion

Lead Conversion in Salesforce is the process of converting a lead into an opportunity, account, and contact. The video addresses the ownership of the resulting records after conversion, explaining that the owner of the lead becomes the owner of the opportunity, account, and contact, which is a key aspect of the lead management process.

πŸ’‘Wire Method

Wire methods in LWC are used to retrieve data from Salesforce and are called automatically by the framework. The video discusses managing dependencies between wire methods by using reactive parameters, which trigger a re-call of the wire method when their values change, illustrating how to handle data dependencies in LWC.

Highlights

Introduction to scenario-based interview questions for Salesforce roles.

Explanation of Salesforce request pipeline and the execution order of automation tools.

How validation rules and workflow rules interact in Salesforce, leading to a potential loophole.

Using platform events to communicate between future methods and LWC components.

The impact of Object-Specific Access settings on DML operations within triggers.

Difference between system and user modes in Apex and their effect on permissions.

How to perform DML on multiple objects within a single operation in Salesforce.

Using external IDs to save related objects in a single transaction.

Clarification on the difference between 'with sharing' and programmatic sharing in Apex.

Behavior of queueable jobs when the submitting transaction is rolled back.

Lead conversion process and how ownership is determined for opportunity, account, and contact.

Managing the calling order of wire methods in LWC components using reactive parameters.

The importance of understanding wardrobe execution in Salesforce for effective automation.

How to enforce user mode in Apex to respect user permissions during DML operations.

The role of platform events in asynchronously handling responses from future methods.

Strategies for handling complex sharing conditions that cannot be met with standard sharing rules.

The practical application of external IDs in DML for creating related records in a single transaction.

How to control the flow of data between wire methods in LWC using reactive properties.

Transcripts

play00:00

foreign

play00:03

[Music]

play00:07

series

play00:16

in which I have already created two

play00:17

videos and covered many scenario based

play00:20

interview questions and if you want to

play00:22

learn about them then please check out

play00:24

those videos and you can find Link in

play00:26

description

play00:27

all right so today in this video we will

play00:30

see more scenario based interview

play00:31

questions

play00:33

which are generally asked in most of

play00:34

Salesforce interviews

play00:36

and we will cover questions related to

play00:38

apex asynchronous apex admin

play00:40

Integrations in lwc

play00:43

and I already have created lwc specific

play00:45

in two questions and answers series

play00:47

in which you will find multiple videos

play00:49

which covers from basic to Advanced lwc

play00:52

interview questions

play00:54

so if you want to learn only lws related

play00:56

questions and answers then you can refer

play00:59

those videos and you can find Link in

play01:00

description okay

play01:02

so let's start with today's first

play01:04

question

play01:06

so the question is

play01:08

suppose we have a validation rule on

play01:10

account object to make website field

play01:12

required and on same account object we

play01:15

have a validation rule to make website

play01:17

feel blank

play01:19

now we have two scenarios here

play01:21

first we have what will happen if we try

play01:24

to insert record without website and

play01:26

another we have what will happen if we

play01:28

save it with website okay so this

play01:31

question is related to or drop execution

play01:34

and you know we have lots of tools and

play01:36

ways to inject our custom Logics and

play01:38

functionalities in Salesforce request

play01:40

pipeline

play01:41

like triggers flows workflows process

play01:44

Builders approvals and many other tools

play01:46

are available in Salesforce

play01:49

so using these tools we can inject our

play01:51

custom Logics in between Salesforce

play01:53

application pipeline for example you

play01:56

want to create tasks when opportunity

play01:58

get created then you can use flows or

play02:00

trigger to create task decode when

play02:02

opportunity record get created okay so

play02:06

now the question is in which order all

play02:08

these tools will get executed

play02:10

like who will get execute first and who

play02:12

will get execute next right so

play02:15

Salesforce already has a predefined

play02:17

order to execute all these automation

play02:19

tools that is called wardrobe execution

play02:23

and as per this wardrobe execution

play02:25

validation rules execute prior to

play02:27

workflow rules

play02:28

so in our first scenario where we are

play02:31

not providing website then validation

play02:33

rule condition will become true

play02:35

and request will be written from here

play02:37

only so in first case record will not

play02:40

get saved into database and error

play02:43

message will appear okay now if we talk

play02:46

about second scenario

play02:47

where we are giving website

play02:49

then validation rule condition will

play02:51

become false so request will move

play02:54

further and reach to workflow rule now

play02:56

what this workflow rule will do

play02:58

it will make that website field blank

play03:01

okay now what will happen without

play03:03

validation rule because you know we have

play03:05

a validation rule to make sure website

play03:07

field should not be blank

play03:09

but after executing validation rule

play03:11

workflow rule making it blank so as per

play03:14

outro Constitution if we are making any

play03:17

field update from workflow rule then

play03:19

only triggers and standard validation

play03:21

rules run again not custom will listen

play03:24

rules so our record will get saved

play03:26

without website I mean website field

play03:29

will be blank

play03:30

why this is happening

play03:32

because custom validation rules are

play03:34

already executed and after that workflow

play03:37

rulemaking website will be blank and as

play03:39

Pro drop execution custom validation

play03:42

rules will not run again so we can say

play03:45

this is a loophole in Salesforce

play03:47

pipeline

play03:48

so in nut sale custom validation rules

play03:50

will not run if you are making field

play03:52

update from workflow rules okay

play03:55

and wardrobe execution is very important

play03:58

topic in Salesforce so if you want a

play04:01

separate detailed video on this then do

play04:03

let me know in the comments

play04:07

now next question we have

play04:09

can we show future method called out

play04:11

response on UI in lwc component

play04:15

it means we have a future method

play04:18

and Performing call out from that

play04:20

then is this possible to show call out

play04:22

response on lwc component

play04:25

then directly this is not possible

play04:28

because the written type of future

play04:29

method is void and you know future

play04:32

method is the part of asynchronous Apex

play04:34

and asynchronous Apex will get executed

play04:36

in another thread so we don't have any

play04:39

control in that and won't be able to

play04:41

return anything from there

play04:43

but we can use platform events to get it

play04:45

done

play04:46

like from future method we can publish a

play04:49

platform event and in lwc component we

play04:52

can subscribe that platform event with

play04:54

the help of EMP APA module

play04:57

so you can see here in this example I

play05:00

have a future method and making call out

play05:02

from here

play05:03

and At Last I am publishing platform

play05:06

again from here

play05:08

and here in this lwc component

play05:11

in Connected callback I have subscribed

play05:14

that platform even with the help of EMP

play05:16

IPA module

play05:17

and this respond Handler better will get

play05:19

executed whenever any platform event

play05:22

will get published

play05:24

so you can put your Logics here

play05:26

and we are passing this response Handler

play05:28

over here with the subscription okay so

play05:32

in nut sale directly we can't achieve

play05:35

this

play05:35

but with the help of platform events we

play05:39

can show future method call out response

play05:40

in lwc component okay

play05:44

now next we have let's say we have two

play05:47

objects

play05:48

object a and object B and rwd is set to

play05:52

private for both objects

play05:54

now suppose user has permission on

play05:57

object a

play05:58

but don't have any permission on object

play06:00

B now if you are going to insert object

play06:03

B record from object a trigger

play06:06

then what will happen in this case Okay

play06:08

so this question just want to check your

play06:10

Salesforce security or sharing model

play06:12

knowledge

play06:14

and let's understand this question again

play06:17

so as per this question we have two

play06:19

objects object a and object B and o w d

play06:23

or by default is set to private for both

play06:25

objects and current user has full

play06:28

permission on object a but don't have

play06:30

any permission on object B and you know

play06:33

user has a permission on object a so

play06:36

whenever he will try to save the code

play06:37

then trigger will get called and try to

play06:40

insert recording object B and as we have

play06:43

seen user don't have any kind of

play06:45

permission on object B

play06:47

so now the question is what will happen

play06:50

here will this object be record insert

play06:52

or not okay so I think now you are clear

play06:55

that this is the case of permissions

play06:58

so in Salesforce generally we have two

play07:01

modes which can be applied on apex while

play07:03

execution

play07:05

first is system mode and another one is

play07:08

user mode

play07:09

so system mode means run Apex code By

play07:12

ignoring user permissions like who is

play07:15

the logged in user and what all

play07:17

permissions he has that doesn't matter

play07:19

and if you are running Apex code in

play07:21

system mode then user permissions are

play07:24

bypassed there

play07:26

and it can access all objects fields and

play07:28

Records By ignoring profile permission

play07:31

set and sharing rules okay

play07:34

and user mode means running Apex code

play07:37

will respect user permissions and can

play07:39

perform only permitted operations for

play07:41

example if user don't have permission to

play07:44

save record and if still you are trying

play07:46

to save then it will throw error so in

play07:49

nut sale system mode bypass user

play07:51

permissions

play07:52

and user mode will follow user

play07:54

permissions okay

play07:56

and system mode is the default mode for

play07:59

Apex code I mean wherever we write Apex

play08:02

code like Apex classes triggers and

play08:04

asynchronous Apex then that will execute

play08:07

in system mode

play08:09

so when we are saving records from

play08:11

trigger then it will be saved without

play08:13

checking user permissions okay

play08:16

but Salesforce provided few ways to

play08:19

enforce user mode with FX code

play08:21

so there are multiple approaches which

play08:24

you can use to enforce user mode and

play08:26

whenever you are going to answer this

play08:28

question then please don't say about

play08:30

with sharing keyword because first of

play08:32

all we can't use with sharing keyword

play08:33

with triggers and with setting only

play08:36

check into code level permissions not

play08:38

object and fill level

play08:40

for objects and field level permissions

play08:42

you can use schema methods or nowadays

play08:45

Salesforce introduced user mode database

play08:47

operations as well

play08:49

like instead of doing all DML operations

play08:52

like this we should write DML operations

play08:54

in this form if you want to enforce user

play08:56

mode

play08:57

like here we need to add add user

play09:00

or if you are using database methods

play09:02

then you can pass access level as a

play09:04

parameter okay

play09:06

and there are many other ways to apply

play09:08

user permissions with Apex code like

play09:10

with security enforced and security dot

play09:13

stripe inaccessible those I will discuss

play09:15

in separate video because this is a long

play09:17

topic so in nut cell our triggers run in

play09:21

system mode

play09:22

and if we are additionally not enforcing

play09:24

user mode

play09:26

then it will insert record without

play09:27

permissions as well so in this case

play09:30

record for object B will be inserted

play09:33

from trigger

play09:34

okay

play09:36

now introvert can also ask you like

play09:38

let's say we are not using additional

play09:40

approach to enforce user mode then

play09:43

record will be inserted right

play09:45

now how user can access that record

play09:49

so if you are talking about the owner

play09:51

like who will be owner of that record

play09:53

then technically the user who initiated

play09:56

the request will be the owner

play09:58

and we have private owd then it should

play10:02

show in the list of user

play10:04

but you know we don't have permission on

play10:06

object level

play10:07

so there is no way on UI to see that

play10:10

record so in nut sale user won't be able

play10:13

to access that record okay

play10:16

now next we have can we perform DML on

play10:19

multiple objects in single DML operation

play10:22

so let's understand this question a

play10:24

little bit more

play10:25

so let's say we have to insert data in

play10:28

five objects

play10:29

and you want to save your DML Governor

play10:32

limits and you know in one DML operation

play10:35

we can insert up to 10 000 records

play10:38

so the question is can I insert these

play10:41

five object records using single DML

play10:43

operation

play10:44

instead of five separate DML operations

play10:47

okay so now I think you got the question

play10:49

so let's discuss on answer so the answer

play10:52

is yes we can insert multiple objects

play10:55

records in single DML statement as well

play10:58

and you can see in this example

play11:00

we have to declare a generic s object

play11:02

list

play11:03

and in this generic s object list

play11:06

we can add our different different

play11:07

object records like here I am adding

play11:10

object a object B C D and E

play11:14

so I am adding five objects records here

play11:16

in this generic cache object list

play11:19

and at last we can perform DML operation

play11:21

like this

play11:23

okay

play11:24

so this will perfectly work

play11:26

and you know all these objects are

play11:29

independent

play11:30

and there is no parent child

play11:32

relationship between these objects

play11:34

now the question is can we save related

play11:37

objects in single transaction

play11:39

because there we require parent record

play11:41

ID in child record right

play11:44

so the answer is yes

play11:47

we can use external ID as a 4M key to

play11:50

create parent and child record in single

play11:52

DML so this is the example you can see

play11:55

here

play11:56

I'm inserting a portrait in account in

play11:58

single DML

play11:59

so what I did here first I have created

play12:02

object or the opportunity

play12:05

then I have created object for account

play12:07

but only provided external ID

play12:10

and edit this account object in this

play12:12

opportunity load account field

play12:15

now here I have created a separate

play12:18

object for account record

play12:20

and here also I'm providing same

play12:21

external ID

play12:23

okay

play12:24

and At Last I am performing DML

play12:27

operation and providing both objects

play12:29

here like account and opportunity so

play12:32

with the help of this external ID

play12:34

Salesforce internally map these records

play12:36

okay

play12:38

so in that sale we can perform DML on

play12:41

multiple objects in single DML operation

play12:43

okay

play12:46

now next we have what is the difference

play12:49

between with sharing and Apex manage

play12:51

setting

play12:52

okay so first let's discuss about with

play12:54

sharing

play12:56

so which setting is the keyword that we

play12:58

generally use with Apex classes to

play13:01

enforce sharing rules

play13:03

for example let's say we are querying

play13:05

data from FX class using soql and by

play13:09

default Apex runs into system context

play13:11

and if we Define owd private for an

play13:14

object then in system context

play13:16

SQL will return all the data without

play13:19

carrying up sharing rules

play13:21

and if we are using with sharing keyword

play13:23

with class definition

play13:25

like this

play13:26

then it will enforce sharing rule for

play13:28

particular class and all the queries

play13:31

written in that class will follow

play13:33

sharing rules and return only allowed

play13:35

records for the user okay

play13:37

and now if we talk about Apex manage

play13:40

setting then we can say this is the type

play13:43

of programmatic sharing which allows you

play13:45

to share a record from Apex

play13:48

so generally we Define Baseline record

play13:50

sharing with owd org white default

play13:53

like in owd we can Define who can access

play13:57

and modify which records so generally we

play14:00

have three options for object public

play14:03

read write

play14:04

it means anyone can see and edit all the

play14:07

records

play14:08

and public read only means anyone can

play14:11

see all the records but only can edit

play14:14

their own records

play14:16

and private means

play14:18

user can only access or modify their own

play14:21

records okay

play14:22

so these settings we can do at object

play14:25

level in owd

play14:27

but let's say you want to share user

play14:29

records with their managers anyone who

play14:31

is in higher role hierarchy

play14:33

then you can use role hierarchy checkbox

play14:36

option

play14:37

and now let's say

play14:39

we have private owwt on an object and if

play14:42

you want to say records with other users

play14:45

then we can use sharing rules and we can

play14:48

create sharing rules in two ways owner

play14:51

based or criteria based so whenever you

play14:54

want to share a particular user records

play14:55

with role or group then you can use

play14:57

owner-based sharing and if you want to

play15:00

say records using with some conditions

play15:02

then you can use criteria based sharing

play15:05

for example you want to share all closed

play15:08

lost opportunities with another group

play15:09

then you can use criteria based sharing

play15:12

okay

play15:14

but let's say you have a complex

play15:16

condition that cannot be implemented in

play15:18

Sharing rules now if you want to say

play15:21

records then you can use FX sharing and

play15:24

this is the example of Apex mini setting

play15:27

so in Salesforce each object has their

play15:30

additional sharing object

play15:32

we don't have to additionally create it

play15:34

it is built in feature in Salesforce and

play15:37

the sale object contains all the record

play15:38

sharing details

play15:40

but if you want to share any object from

play15:42

Apex

play15:43

then you have to insert new record into

play15:45

this and you need to provide here which

play15:47

record you want to share with which user

play15:49

okay

play15:51

so you can see here I have job custom

play15:53

object

play15:57

now here I am telling this record I want

play16:00

to share and here I am giving the user

play16:03

ID

play16:03

to whom I want to share this record

play16:06

and here we can Define the access level

play16:09

and at last we can insert this recording

play16:12

to Salesforce database

play16:14

so this is how we can say array record

play16:16

with the help of Apex

play16:18

so in nut sale with sharing and for

play16:20

sharing rule in Apex classes

play16:23

and minutes setting is used to

play16:24

programmatically save records okay

play16:29

now next we have what will happen if f x

play16:32

transaction roll back after nkqable job

play16:36

so it means let's say you are submitting

play16:38

a queueable job from Apex transaction

play16:41

but somehow if current transition get

play16:43

rolled back then what will happen with

play16:46

that queueable job

play16:47

will that still execute or not because

play16:50

you know curable job is the part of

play16:52

asynchronous Apex and asynchronous Apex

play16:54

get executing different thread but if

play16:57

submitting transaction get rolled back

play16:59

then Salesforce does not execute

play17:01

asynchronous jobs as well okay

play17:04

so answer will be no job will not

play17:07

processed okay

play17:10

now next we have assume we have a lead

play17:13

and owner of that lead is q

play17:16

then after conversion who will be the

play17:18

owner of opportunity account and contact

play17:21

so this question is related to sales

play17:23

lead conversion process

play17:25

so you know a lead can be owned by

play17:27

multiple users with the help of queue I

play17:30

mean we can set a queue as a lead owner

play17:33

so multiple users can work on the same

play17:35

lead

play17:36

but when we convert lead into

play17:38

opportunity

play17:39

then generally Salesforce created three

play17:41

objects opportunity account and contact

play17:45

and by default lead owner is the owner

play17:47

of these three objects but we can't set

play17:50

queue as a owner of these objects

play17:52

then who will be the owner of these

play17:54

records

play17:55

okay so the owner will get changed

play17:58

automatically to the user who is

play17:59

converting the lead

play18:01

so we can say current user who is

play18:03

converting the lead will be the owner

play18:05

okay

play18:07

now next we have can we set calling

play18:10

order of wire methods in lwc or in other

play18:13

words can we call one wire method after

play18:16

another in lwc so you know we can have

play18:19

multiple wire methods in same lwc

play18:21

component and one wire method may be

play18:24

dependent on another I mean you may

play18:26

require one wire methyl response into

play18:28

another so how we can handle this

play18:30

situation because you know wire methods

play18:33

call automatically wipe framework we

play18:35

don't have any control on that

play18:37

so directly this is not possible but

play18:40

what we can do we can pass reactive

play18:43

parameters in dependent wire method and

play18:45

change that parameter value from first

play18:47

wire method

play18:49

and reactive parameter means whenever

play18:51

the value of parameter will get changed

play18:53

then wire method will call again so

play18:56

let's understand this with example so I

play18:59

have two wire methods here to get

play19:01

accounts and contacts

play19:03

in first method I am getting accounts

play19:06

list

play19:06

and in second I am getting account

play19:08

contacts list and passing account IDs

play19:11

parameter and here I'm assigning account

play19:14

ID property with dollar sign so this is

play19:17

how we can make a parameter reactive

play19:20

we just need to add dollar with property

play19:22

name okay

play19:23

now in first method when I get accounts

play19:26

then I'm assigning first account ID to

play19:28

this account ID property

play19:30

and when this account ID property value

play19:32

will get changed then this get context

play19:35

method will again call due to this

play19:37

reactive parameter okay

play19:39

so directly there is no way to control

play19:41

calling order of wire methods but we can

play19:44

say dependencies using reactive

play19:46

parameters so whenever parameter value

play19:48

will get changed then wire method will

play19:51

recall okay

play19:53

so that's it for this video and if you

play19:56

want more videos in this series then do

play19:58

let me know in the comments and if you

play20:01

learned anything new from this video

play20:02

then please like And subscribe my

play20:04

YouTube channel

play20:06

I will see you in next video

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
SalesforceInterviewApexLWCValidationSecurityAsynchronousDMLGovernor LimitsSharing RulesQueueable Jobs