0

I would like to display the fields and provide the option to Map the Salesforce Lead fields. I would like to get the selected fields values along with key while I'm click the Submit button in the parent component.

  • Each field is associated with Salesforce fields(dropdown)

Can any one help us to achieve us this functionality.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="singnalsList" type="Map"/>   
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <aura:iteration items="{!v.singnalsList.signals}" var="sgn">  
      <c:MyLightDemoChild aura:id="signalId" label="{!sgn.title}" selectedValue="{!sgn.key}"/>
    </aura:iteration>
    <br/>

Controller

({
    doInit : function(component, event, helper) {

        var a='{"signals":[{"key":"url","title":"URL","mapped_field_api_name":"url__c","is_enabled":false},{"key":"Facebook","title":"Facebook","mapped_field_api_name":"Facebook__c","is_enabled":false}]}';
       // JSON.parse(a);
        component.set("v.singnalsList",JSON.parse(a));
    },
    GetSelectedList: function(component, event, helper) {
     //I'm trying to catch all selected fields here   
     alert('---'+component.find("signalId")+'---'+$A.util.isArray(component.find("signalId")));       
    }
})

Component

<aura:component >
 <aura:attribute name="options" type="List" />
    <aura:attribute name="selectedValue" type="String" default=""/>
    <aura:attribute name="label" type="String" default=""/>

    <aura:handler name="init" value="{!this}" action="{!c.loadOptions}" />
    <lightning:select name="mySelect" label="{!v.label}" aura:id="mySelect" value="{!v.selectedValue}">
        <option value="">choose one...</option>
         <aura:iteration items="{!v.options}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
        </aura:iteration>
    </lightning:select>
</aura:component>

Controller

({
    loadOptions: function (component, event, helper) {
        var opts = [
            { value: "Url", label: "Website" },
            { value: "Company", label: "Company" },
            { value: "LeadSource", label: "LeadSource" },
            { value: "Name", label: "Name" },
            { value: "Facebook", label: "Facebook" }
        ];
        component.set("v.options", opts);
    }
})
  • it would help if you included what problem you are facing, where you are stuck (code lines included) errors if any and what you have tried to fix the issue. – glls Mar 14 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.