+ Start a Discussion
Stéphane C.Stéphane C. 

How to overwrite "New quote" action with Lightning component?

I want to overwrite "New quote" action with Lightning component. I have follow this trailhead (https://trailhead.salesforce.com/fr/projects/workshop-override-standard-action) but I have some errors.

CMP quoteDialog
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >

    <aura:attribute name="picklistValues" type="Object" />
	<c:PicklistValues sObjectName="Quote" fieldName="productFamily__c" picklistValues="{!v.picklistValues}" />

    <lightning:select aura:id="quoteFamily" name="quoteFamily" label="Family">
            <aura:iteration items="{!v.picklistValues}" var="item">
    			<option value="{!item}">{!item}</option>
			</aura:iteration>
    </lightning:select>
	<lightning:button variant="neutral" label="Cancel" />
	<lightning:button variant="brand" label="Submit" />

</aura:component>
I don't think I have to change another thing.
 
NagendraNagendra (Salesforce Developers) 
Hi,

Please try this.
<aura:attribute name="colors" type="String[]" /> 

<lightning:select aura:id="quoteModele" name="quoteModele" label="Modele"
  onchange="{!c.onChangeModele}">
        <aura:iteration items="{!v.picklistValues}" var="item">
            <option value="{!item}">{!item}</option>
        </aura:iteration>
</lightning:select>

<lightning:select aura:id="quoteColor" name="quoteColor" label="Color">
    <aura:iteration items="{!v.colors}" var="item">
        <option value="{!item}">{!item}</option>
    </aura:iteration>
</lightning:select>
And in your javascript controller:
onChangeModele : function(component, event, helper) {
    // function in your apex controller class
    var action = component.get("c.getColors");

    // params in your apex controller class
    action.setParams({ modele: component.find("quoteModele").get("v.value") }); 
    action.setCallback(this, function(result){
            if(result.getState() == 'SUCCESS') {
                var values = result.getReturnValue();
                component.set("v.colors", values);
            } else {
                alert('ERROR');
            }
        });
        $A.enqueueAction(action);
}
Hope this helps.

Kindly mark this as solved if the information was helpful.

Thanks,
Nagendra

 
Stéphane C.Stéphane C.
Thank you Nagendra,

I will test your code soon.