function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael M 

Report filtered based on history

Hello, I have a task to create a bit of a complicated report, and I am wondering if and how this is possible. 

The background is that our Lead object's "Status" picklist field has 2 values (for the purposes of this report) : "Accepted" and "Pending Opportunity". 

We want a report that contains data based on the following criteria:
- All Leads WHERE 1) the status was at any point in their history "Accepted" , and 2) the lead was converted into an opporunity, and 3) that opportunity''s stage became closed-won. 

Is this possible to do, and if so, how? (In case this is helpful, our Leads are connected to our Opportunities in the sense that both Leads and Opportunities have a lookup to the same Account)

If a formal "report" is not supported, can this be done with SOQL queries? 
Best Answer chosen by Michael M
Sowjanya Hegde 13Sowjanya Hegde 13
step 1: Create a checkbox field "Accepted__c" in Lead object, and create workflow with the condition if "Accepted", checkbox should be set to true. This will check the checkbox to true if the lead is set to "Accepted" at some point and it will remain checked even if it is set to "Pending Opportunity" later at some point. 
Create the similar field on the opportunity object:
Label: Accepted Lead
Map this field while converting from Lead to opportunity
map: Lead.Accepted__c -> Opportunity.Accepted_Lead__c

step 2: 
Setup a checkbox Field on Lead that will always default to Checked - 
Label: Was Created From Lead
Type: Checkbox
Default: Checked
Note: hide this field in the Page Layout

create a similar field on the Opportunity- 
Label: Was Created From Lead
Type: Checkbox
Default: Unchecked
Note: hide this field on the Page Layout
Now, to the Lead Field Mapping section
Map the Lead.[Was Created from Lead] to Opportunity.[Was Created From Lead]
That is it.

Create a report of report type Opportunity:
Filter: Accepted_Lead__c = true
Was_Created_From_Lead__c = true
stage =closed-won
 

All Answers

AbhishekAbhishek (Salesforce Developers) 
I think your query is still in Idea face,

https://trailblazer.salesforce.com/ideaView?id=0873A000000Ljz0QAC

Check it once.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
Michael MMichael M
Hi Abhishek, thank you for your comment. 

I am thinking of this: What if I create a new checkbox field called "Accepted at some point". 

Is there any way I can run a SOQL query to find every Lead where the status was at some point "accepted" and if so check off that box?
Sowjanya Hegde 13Sowjanya Hegde 13
step 1: Create a checkbox field "Accepted__c" in Lead object, and create workflow with the condition if "Accepted", checkbox should be set to true. This will check the checkbox to true if the lead is set to "Accepted" at some point and it will remain checked even if it is set to "Pending Opportunity" later at some point. 
Create the similar field on the opportunity object:
Label: Accepted Lead
Map this field while converting from Lead to opportunity
map: Lead.Accepted__c -> Opportunity.Accepted_Lead__c

step 2: 
Setup a checkbox Field on Lead that will always default to Checked - 
Label: Was Created From Lead
Type: Checkbox
Default: Checked
Note: hide this field in the Page Layout

create a similar field on the Opportunity- 
Label: Was Created From Lead
Type: Checkbox
Default: Unchecked
Note: hide this field on the Page Layout
Now, to the Lead Field Mapping section
Map the Lead.[Was Created from Lead] to Opportunity.[Was Created From Lead]
That is it.

Create a report of report type Opportunity:
Filter: Accepted_Lead__c = true
Was_Created_From_Lead__c = true
stage =closed-won
 
This was selected as the best answer
Michael MMichael M
Thank you! 
How would I update the existing records?