Pages

Thursday, May 12, 2016

Campaign Member Status & Responded


New campaigns have two default member status values: “Sent” and “Responded”. You can edit them or create new ones.
  • Click Advanced Setup on a campaign detail page.
  • Click Edit.
  • Update the existing entries or add new values.
  • Click Add More as needed to add additional entries. You can add up to 50 entries.
  • Select one entry as the “Default” value.
  • Choose which values will be counted as “Responded.”  Members with “Responded” values are tallied in the Total Responses field on the campaign. Status marked as Responded will cause a field called Responded to True (API Name = HasResponded)

But, you will also notice there is a field in Campaign Member object called Status, and when you click that field, you will see a few values there, and there are no New button to add value.

So, how this work? When user add new Status entry in Campaign detail page, if the Status doesn't exist in field Status in setup, system will auto add the new values, this is totally different with others picklist values.

Modifying the Responded checkbox has broad effects. When you select or deselect the Responded
checkbox, campaign statistics and campaign member details change accordingly. Specifically, the fields Responded, Last Responded Date, and Last Modified change on the campaign member record. For example, if you're working with a status called “Attended” and you select the Responded checkbox for it, existing campaign members whose status is “Attended” will then be counted as responses in campaign statistics and the aforementioned date fields will update.


Reference: Customizing Campaign Setup



Salesforce: View All Campaign Members Report


For those of you who have got an error message when clicking the View All Campaign Members link in a Campaign and get the error message "URL Has Moved".

If you are a Salesforce admin, follow this step to fix it permanently in your org:

1. Navigate to Setup | Customize | Campaign | Buttons, Links, and Actions
2. Click Edit in the View All Campaign Members link
3. Edit the URL from
   /camp/rptcmpgncalldown.jsp?scope=1&scopeid={!Campaign_Name}
   to
   /00O?scope=1&rt=5&scopeid={!Campaign.Name}

4. Done

Now, all of your users should get the right report name "Campaign Call Down Report".


Edit Aug 2023, the above step is only applied in Classic, but who is using Classic in 2023?

To get a similar report in Lightning:
  • Create a new report using the "Campaigns with Campaign Members" report type, make sure to store the report in a public folder or other folders that are accessible by your users
  • Set filter: Show all campaigns and filter with a campaign name
  • Note the report URL
  • Add a new custom link in the Campaign object under "Buttons, Links, and Actions"
  • Add a report parameter at the end of the URL, e.g. https://mydomain.lightning.force.com/lightning/r/Report/00OHt000007MOIKMA4/view?fv0={!Campaign.Name}
  • Add the custom link to the Campaign page layout and save it



Salesforce: Who add Contact/Lead to Campaign?

In many organizations, Campaign is owned by Marketing, but Contact and Lead is owned by Sales. By default, all users can add Contact/Lead to Campaign as Campaign member.

There are many ways to add Contact/Lead to a Campaign as member, see this blog.

You can run a report with report type 'Campaigns with Campaign Members' to get all the members related to the campaign and other information for that members.

When you run the report, notice 3 important dates:
- Member First Associated Date: when is the member added to Campaign
- Member Status Update Date: when is last status update of the member
- Member First Responded Date: when is the status flip to Responded

But, the report do not have info on who add the Contact/Lead as member, it can be added by sales rep, marketing user, or by someone else.

Solution:
1. Custom Field
Create a custom formula field with return type = Text.
CreatedBy.FirstName + " " + CreatedBy.LastName
So, just use the custom field to report type 'Campaigns with Campaign Members'.

2. Custom Report Type
Create custom report with Primary object = Campaigns and relate to Campaign Members.
Find Created By: Full Name field in Campaign Members object.
This field will show who is the user who add the Contact/Lead as member.




Tuesday, April 26, 2016

Salesforce: Store Approval Comments to Notes

Use Case: we need to capture Comments type by approver when approve or reject in Approval process as Notes.

Assume that you already have the following:
- Status picklist field: Draft, In Progress, Rejected, Approved
- Approval Process with actions to update status to Rejected or Approved

Solutions:
1. Process Builder 
Process to trigger when the status change to Approved or Rejected

a. Select the object and make sure to select "when a record is created or edited"
b. Criteria: make sure both values captured with OR logic

c. Action: call Flow with passing Record Id as flow variable


2. Autolaunched Flow
Flow designer:

a. Lookup to Process Instance object, filter to Record Id and Approval Process Id, you need to store Approval Process Id into a constant.
Store the result (Id and Status) to a sobject variables, as this will always return only 1 record, we can use Sobject Variables.

b. Lookup to Process Instance Step object, filter to Process Instance Id, Step Status equal to Rejected and Approved. Store the result (Comments, StepStatus, and ActorId) to a sobject Collecton variables, this lookup may return more than 1 record, so we should use Sobject Collection Variables.

c. Loop the Process Instance Step object
Copy each record from Sobject Collection Variables to Sobject Variables.

d. Assign Sobject Variables
Populated fields to a new Sobject Variables.

formulaBody is a formula resource = {!lvProcessInstanceSteps.ActorId} & " | " &
 TEXT({!lvProcessInstanceSteps.StepStatus}) & " | " &
{!lvProcessInstanceSteps.Comments}
Approval Comment is just a text for note title.

e. Assign Sobject Collection Variables
Add Sobject Variables to new Sobject Collection Variables

f. Create Notes


So, when it is approved / rejected, a note will be automatically created.


Here is the notes content:


With slight adjustment in the Flow, you can change the flow to store approval history into a custom object.



Monday, April 25, 2016

Salesforce: Retrieving Metadata with Developer Workbench

Use Case: as time goes by, we have more and more Process Builder calling Auto Launched Flow, we found an Auto Launched Flow and not sure is called by Process Builder.

Solution:
Use Force.com IDE or MavensMate to download the metadata file, but if your machine is not installed with any IDE, you can use Developer Workbench to download the metadata XML file -- huge thanks to Doug Ayers for the tips.

1. Prepare the Package 

A. Using Package XML file
Save the file as package.xml or any other name
 <?xml version="1.0" encoding="UTF-8"?>  
 <Package xmlns="http://soap.sforce.com/2006/04/metadata">  
   <types>  
     <members>*</members>  
     <name>Flow</name>  
   </types>  
   <types>  
     <members>*</members>  
     <name>FlowDefinition</name>  
   </types>  
   <version>36.0</version>  
 </Package>  
** to get the name tag, you can use this free tool Package Builder

B. Create Package
Instead of creating XML file as above, the other option is by creating Package from Salesforce menu Setup | Create | Packages, see this blog for complete reference Getting Unstuck.


2. Developer Workbench
- Click Migration | Retrieve
- Select the XML file created for "Unpackaged Manifest"
- or enter the Package Name, if you use option B - Create Package
- Check "Single Package"

- Click Next button
- Click Retrieve button

- Click "Download ZIP File" link when done


3. Extract and Find
A zip file will be download, you need to extract it and using tool like Notepad++ to find the metadata you need. In my use case as above, I am looking for <actionType>flow</actionType> to find all Flow called by Process Builder.



Reference:

Salesforce: Not allow Opportunity back to the previous Stage


Use Case: biz team decide to set a rule that Opportunity Stage are not allowed back to the previous Stage and team decide not to add number in the Stage as prefix.

Solution: create a validation rule with hard code each stage with a number, but the number only valid for the validation rule.

Let's say this is our Stage for open Opportunity from beginning till before closed.
  • Prospecting
  • Qualification
  • Needs Analysis
  • Value Proposition
  • Id. Decision Makers
  • Perception Analysis
  • Proposal/Price Quote
  • Negotiation/Review

Validation rule:

 CASE   
 (   
      StageName ,   
           "Prospecting", 1,   
           "Qualification", 2,   
           "Needs Analysis", 3,   
           "Value Proposition", 4,   
           "Id. Decision Makers", 5,   
           "Perception Analysis", 6,       
           "Proposal/Price Quote", 7,   
           "Negotiation/Review", 8,   
           0   
 )   
 <   
 CASE   
 (   
      PRIORVALUE(StageName) ,   
           "Prospecting", 1,   
           "Qualification", 2,   
           "Needs Analysis", 3,   
           "Value Proposition", 4,   
           "Id. Decision Makers", 5,   
           "Perception Analysis", 6,       
           "Proposal/Price Quote", 7,   
           "Negotiation/Review", 8,   
           0   
 )  



Page-level ad