Overview
Available in V1.39.X and later.
FCROppNew is a lightning action override component that pre-populates Opportunity fields from a contact or account. Creating New Opportunities Through the Salesforce UI explains how to override the New Opportunity button to navigate to the component from a contact or account record page.
Starting in V1.39.X, FCROppNew implements the isUrlAddressable interface, which allows a developer to redirect a user directly to this component.
This 2-step article covers how to navigate to the opportunity creation page through code, providing developers with more flexibility to create an opportunity from any lightning component.
Step1: Include lightning:navigation instance in your lightning component
<aura:component description="Your calling component">
<aura:attribute name="contID" type="ID"/>
<lightning:navigation aura:id="navService"/>
<lightning:button label="Navigate" onclick="{!c.handleClick}"/>
</aura:component>
In this example we will make the navigation after a button click.
Step 2: Define a page reference and navigate to FCROppNew
handleClick: function(cmp, event, helper){
var contactID = cmp.get("v.contID");
var navService = cmp.find("navService");
var pageReference = {
type: 'standard__component',
attributes: {
componentName: 'FCRM__FCROppNew',
},
state: {
"FCRM__recId": contactID,
"FCRM__oppRecTypeId": "012XXXXXXXXXXXXXXX"
}
};
event.preventDefault();
navService.navigate(pageReference);
}
- componentName must be 'FCRM__FCROppNew'.
- FCROppNew requires a contact/account record ID to work correctly. You must pass a valid ID to 'FCRM__recID'.
- Optional: You can pass a valid opportunity record type ID to use when creating an opportunity. Otherwise the default record type for the user profile is used.
Comments
0 comments
Please sign in to leave a comment.