Tag: admin release exam

Yes, it is sometimes a good idea to hard-code values (for example, while learning Apex or Process Builder or hard code Pie value i.e. 3.14), but there’s no simple rule as to when; it depends completely on context. If you’re hard coding the value of the earth’s gravitational constant, no one’s going to care. If you hard code the record ID (Queue, Group or Salesforce record Id, etc.), you’re in for trouble. Time and time again, I see Apex code, Flows or Processes that contains hard-coded Ids, whether it’s the Description field, a user ID, or even a group ID, etc. The problem with hard coding IDs is that any changes need to be made to the Flow or Process itself, test again, and then deploy to production org. The record IDs can change, for example between a sandbox and a production environment. It might be possible that a queue (Dupe Management) has different ID in a sandbox and a Production org. Let’s start with a business use case

Business Use case

Donna Serdula is working as System administrator at Universal Containers. She has received a requirement from higher management whenever an account is created for Industry Not For Profit, auto create a case and assign it to Nonprofit Experts queue to verify organization’s nonprofit status.

Solution of above business requirement

To solve the above business requirement, first of all, we have to create a queue as shown in the following screenshot

Nonprofit Experts – Queue

Now you can refer the Queue id while creating a case through Process Builder.

Create a record – Process action

The problem with this approach (Hard-coding queue ID) is, If you are developing in the Sandbox, the IDs of the newly created Queue will change when you get to Production, and you have to do the rework.

It is always good to follow Salesforce best practices where possible. At the moment Process Builder doesn’t allow to query and save the outcome (means record ID, field value, etc.) in a variable, even you can’t save newly created case ID (case created through Create a Record – process action) in a variable.

An Opportunity team is a set of users that usually work together on an opportunity. A typical Opportunity Team might include the account manager, the sales representative, and a pre-sales consultant. In Salesforce a user can follow Chatter groups or Records. As of now, Salesforce does not have any out of the box functionality to auto follow records when a user is added to a team or etc., apart from the Automatically follow records that you created.Let’s start with a business use case

Business Use Case

Rachel Gillett is working as System administrator in Universal Container. She has received a requirement from the management when a new user is added to the Opportunity team, then auto adds him as Opportunity follower.

Solution for the above business requirement

There are a few possible solutions for the above business scenario, but we’ll use Flowand Process Builder to solve the above business requirement. Follow the below instructions to create a Process Builder andFlow to resolving the above business requirement

1.click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows2.Click onNew Flow, it will open the Flow canvas for you. Now create an SObject Variable Sov_OpportunityTeamMemberto store the Opportunity Team Member data (we will pass the value through Process Builder), as shown in the following screenshot

SObject Variable

3. The next step is to use EntitySubscription object to check whether the Opportunity team member is already following the Opportunity or not. To do this drag-and-drop a Record Lookup (Enter the name Check follower detail) onto the canvas and map the fields according to below details

Select Object EntitySubscription

For criteria selectParentId= {!Sov_OpportunityTeamMember.OpportunityId} andSubscriberId= {!Sov_OpportunityTeamMember.UserId}. Save the record Id in one Text variable as shown in the following screenshot

Check follower detail

4. Based on{!VarT_SubscriberDetail}we will decide whether we have to add a new Opportunity Team Member to Opportunity follower or not. Drag-and-drop a Decision Element (Enter the name Add as follower or skip) onto the canvas and map the fields according to the following screenshot

Add as a follower or skip

5.The final step is to add a new opportunity team member to Opportunity follower. To do this drag-and-drop Record Create element (Enter the name Opportunity team member to Opportunity follower) onto the canvas and map the fields according to below details

Select Object EntitySubscription

For criteria selectParentId= {!Sov_OpportunityTeamMember.OpportunityId} andSubscriberId= {!Sov_OpportunityTeamMember.UserId}, as shown in the following screenshot

Opportunity team member to Opportunity follower

6. Finally, yourFlowwill look like the following screenshot

7. Saveyour flow with nameAdd OTM to Opportunity follower and close the canvas. Don’t forget to Activatethe Flow.

Launch a Flow from Process Builder

Our next task is to create a Process Builder on theOpportunity Team Member object to launch a Flow. To create a Process Builder on theOpportunity Team Member object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder and click on the New button, Enter Name, API Name and then click on the Save button2. To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name (Use Add OTM to Opportunity follower PB as name), API Name and Description as shown in the below screenshot

Define Process Properties

3. Click onObjectnode to add object and then selectOpportunity Team Member object. For the entry criteria, Select onlywhen a record is created, as shown in the below screenshot

Evaluation Criteria

4. The next task is to add ProcessCriteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions(In this case select No criteria—just execute the actions!) and click on the Save button as shown in the following screenshot

Process Criteria

5. The next step is to addan Immediate action to Process. Click onAdd Action(Under Immediate actions), Select the type of action to create (In our case Flows), and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows

6. Once you are done, click on theSave button, it will redirect you to Process canvas. Finally, theProcess will look like the following screenshot