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
Andrew GAndrew G 

Open the opportunity for associated converted lead

short version,
I have had to create a lead conversion process where we are using Apex code to convert the lead.  When all the required fields have been entered, on Save, the record is converted.  I have created a Process Builder that invokes some Apex which converts the lead.  The behaviour is that the lead is still displayed but the status has been updated.

NOW, the client wants to have the system open the related Opportunity that has been created.  I am at a loss on how to do this.

I would appreciate some help / guidance.  I'm thinking either something to have the Apex class open the record, or can I do a lightning component or similar in the converted lead?

Regards
Andrew
Best Answer chosen by Andrew G
Andrew GAndrew G
Hi Anutej

Whilst a good example, I had already managed the conversion process.

To give access to the created opportunity, i ended up creating a simple component
<aura:component description="convertedOpportunity" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="fields" type="String[]" default="['ConvertedOpportunityId']" />
    <div><br/></div>
    <div class ="white">
        <div class="slds-text-heading_label" >Newly created Opportunity</div>
    	<lightning:recordForm recordId="{!v.recordId}"
                          objectApiName="Lead"
                          mode="readonly"
                          fields="{!v.fields}" />
    </div>
</aura:component>

a bit crude, but accomplished what was needed.

regards
Andrew
 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Andrew,

>> https://www.sfdcamplified.com/2020/03/custom-lead-conversion-in-lightning-web-component.html

I found this custom lwc implementation where in they are converting the lead and navigating to account record page instead of that I think you can modify this below part of code to make it navigate to opportunity record page:

 .then(result => {
        // Clear the user enter values
        this.taskRecord = {};
        this.accRecordId=result;

        window.console.log('result ===> '+result);
        // Show success messsage
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: this.accRecordId,
                objectApiName: 'Account',
                actionName: 'view'
            }
        });

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.
Andrew GAndrew G
Hi Anutej

Whilst a good example, I had already managed the conversion process.

To give access to the created opportunity, i ended up creating a simple component
<aura:component description="convertedOpportunity" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="fields" type="String[]" default="['ConvertedOpportunityId']" />
    <div><br/></div>
    <div class ="white">
        <div class="slds-text-heading_label" >Newly created Opportunity</div>
    	<lightning:recordForm recordId="{!v.recordId}"
                          objectApiName="Lead"
                          mode="readonly"
                          fields="{!v.fields}" />
    </div>
</aura:component>

a bit crude, but accomplished what was needed.

regards
Andrew
 
This was selected as the best answer
ANUTEJANUTEJ (Salesforce Developers) 
Glad to know you were able to solve your scenario, as you were implementing a custom lead conversion so I thought that was an appropriate example to share.

I think if you can select the best answer it might be useful for other community members in the future.
Andrew GAndrew G
Hi Anutej

I usually don't like selecting my own answer as best, but I feel it answer the problem directly. 

For anyone else, the linked example provided by Anutej is worth a visit if you are doing a custom lead conversion.  

Regards
Andrew