In this session let's understand how to use process builder to auto create child records.
In fact in the previous video we did a similar requirement that we use to process builder to auto create
a record which wasn't the same object right.
But in this one really be auto creating a child records.
So basically on a different object and thus a business use case isn't looking more complicated than
the one that we discussed in the previous media and here is the business use case the requirement is
that whenever an opportunity gets closed successfully a new contract needs to be automatically created
for the opportunities account.
And the contracts account should be the opportunities account the state does as draft contract start
date as opportunities close did contact them six months and notify the opportunity or not.
So these are all the actions that need to take place and what is the scenario in this scenario is that
whenever an opportunity gets closed successfully so that does a letter triggering criteria.
So when this happens automatically all these should happen right.
So opportunity gets close to successfully meaning the opportunity stage equals close to one.
So whenever an opportunity of a card gets abated with the stage name as close to one then a new contract
that a card needs to get created and also like we have the the specifications for the various fields
that we need for creating that contract require and here.
If you see we are creating a contract record which is basically a child off the account.
So Fiat creating a child record a card in a different object unlike the previous one when we created
a new record but it was pretty much on the same object.
But this is a different object
so there's this creation of child records.
In fact if we consider the declarative automation tools and sets forth process builder and flow builder
are all the only tools which supports creating child records.
It doesn't happen with the other automation tools that we have in Salesforce.
Otherwise it picks and we should force is always an option but that is coding but from the declarative
features process builder and flow builder our only options and process building is definitely a very
efficient tool.
So now let's quickly use a process builder to replicate the scenario
openness Sandoval's Dev liquidation goal for process builder
or to create taking its record.
This is the one that we previously created and activated that.
So let's go for a new process fill in the details.
I've given the name as to create contract on account and they are being employed populated description.
App please do give a more meaningful description and we need to specify when the process starts here
and the process should start when the right chord changes right.
Basically when the opportunity record changes then the opportunity stage name gets updated to close
to 1.
This process should start so we have mentioned record changes save and now all added process scandalous
opens.
And here let's do these remaining first.
Let's add the object choose the object and specified length to start the process.
So basically what is the beginning of a process.
The opportunity stage name.
So the object this opportunity and start the process one living at a card is created or created or edited
basically in our case it is created or edited.
Right because opportunity can be created as close to one so it is edited say okay.
And now that that is defined let's move on to the criteria criteria give a good criteria.
Name will be checking if the opportunity stage is close to 1 and the good.
The criteria for executing actions okay.
Let's say the conditions are met.
All right.
And now let's add other conditions.
The condition is that the opportunity stage
equals and that's a big list close to one.
So that is a condition right.
Then the opportunity stage is close to one.
Then we have to fight the process.
All right.
Our criteria is set.
Now let's add the actions so what.
What does action that we need to do we need to create a new contract required.
Right.
So let's choose a create records.
We need to create a new contract a.
Give the action name create new contract.
Find the right guard type.
This is the standard contract object.
So I've chosen.
Contract object.
And now we have to set the field values the field values as we discussed in the previous video.
Whenever we create a class we have to be very mindful about the fees that are mandatory in the object.
So those fields need to be given values.
Otherwise the process literally it out on top of it.
On top of the mandatory values we need to add appropriate fields.
If businesses is specific about any particular field values.
So the mandatory fees and the fees given by the business both these fees should be added.
Now that let's just add those fees which is mentioned and the requirement the contract account is the
opportunities account
so if we take a look at the contracts required.
Let me try creating a new contract.
If you see this account is mandatory.
All right.
So whenever we create a contract required we need to tag it to the account and also we see that a status
contract started and contract done these deals end mandatory.
All right.
So all these fields needs to be populated with some value for creating a contract record.
So the first is the account
the businesses the contracts account is the opportunities account.
So what we are going to do is first let let's pick that field the account diety because it is mandatory
to showing here.
Let me say field reference and the value it is the opportunities account.
All right.
So now we have mapped the account diary field.
That is a contract Satcom is mapped to the opportunities account.
So we have mapped the philosophy and the next field is the status field the tasks to be set to draft
so status.
It's a pick list give a desk a draft the contract start date is the opportunities close date
OK.
Again it's a field reference because if it is data then basically they are giving in some values but
we are not giving any values message field reference is the opportunities clause date right.
OK.
You have mapped it the contract on the six months.
If you see this value is constant.
This is data right.
So let's input the data.
The contract.
Okay.
So no that is 6.
All right.
And now that like all the field values are set let's go ahead and save this action.
Perfect.
We have added the first action but is that all.
Not at all right.
We have one more action that needs to be done that does notify the opportunity owner.
So the first action is to create a new contract.
And the second action is to notify the opportunity owner.
So in that case the action that we are going to select is email alert and the action name is notified
opportunity owner have given us notify opportunity owner and now email alerts.
So if you click on this email alert you ask to do not see any email alerts appearing out here.
Right.
Why.
Because there are more existing email alerts for this particular object opportunity object.
So first let's create one email alert and then associated here.
So for creating one new email alert.
Fill in the details
as this is more for the understanding purpose I have just associated one existing email template and
just read the details that also feel safe.
Perfect.
So now we have created an email alert.
We are not going to use this email alert in other process builder the email alert name is a notify opportunity
owner.
So the moment you start typing it it automatically appears out here.
Perfect save
full effect.
So we are almost done.
All right.
We have configured our process ballooned in such a way that it satisfies this requirement.
Opportunity guest glowed successfully.
So our criteria is opportunity stage name is close to one and a new contract needs to be created.
So we have added action for creating recall the new contract required.
And also we have created an email alert to notify the opportunity on a full effect.
So in this scenario there are two actions out here.
So always uses a show more to see all the actions which are defined and also one other thing out here
is that are more than one action the actions get executed in the order that it appears in the canvas
that is their so in our scenario first a new contract gets created and then email is fired at opportunity
owner.
Perfect.
So now that the entire process is configured let's go ahead and activate the process confirm perfect
our processes activated.
Now let's go and test it out and just choose any opportunity here your put our body can even create
one and also make sure that the stage is not close to one.
So you don't begin observe the changes.
So now the stage is not close to one.
What we are going to do is we are going to update the stage to close to 1
by doing so what would have happened is now that the process would have got fired.
So then that process triggers what happens a new contract gets created.
Right.
So now if we navigate to the so-called we should see a new contract that gets created.
Right.
So for that account a new contract required is created
for the new contract regard.
If you see the icon name redacted to the opportunity account.
So the same look on the stack and the start date.
The that is the opportunities clause date.
The same date the stack and the contract on the sixth month.
So automatically they indeed get calculated so basically the first action guard completed successfully.
The second option notify the opportunity on it.
I received an email with the email template which was that this deck.
So the second action also blocked completed successfully.
So this is how we use a process builder to create a child records in the system and it is just not a
bold one action we can add a multiple actions but the process builder in the upcoming redo is let's
get into more business use cases.