0

I have a button and a dropdown list with the lightning component like below where when I click on the button it shows a popup with the dropdown. I am trying to call Apex Class method (where I need to be using Case Id in SOQL query) on the selection of the dropdown is made

<aura:component implements="flexipage:availableForRecordHome" access="global"  controller="manageCase"  >
  <aura:attribute name="isOpen" type="boolean" default="false"/>         
  <lightning:button variant="brand" label="Transfer Case" onclick="{! c.openModel }" />
  <aura:if isTrue="{!v.isOpen}">

   <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
       <div class="slds-modal__container">
          <header class="slds-modal__header">
          <lightning:buttonIcon iconName="utility:close"                                                  onclick="{! c.closeModel }" alternativeText="close"                                                   variant="bare-inverse" class="slds-modal__close"/>
           <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Transfer Case </h2>
           <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
           <lightning:select aura:id="select" name="select" label="Select" onchange="{! c.onChange }">
                            <option value="">choose one...</option>
                            <option value ="JaxServices">Jax Services</option> 
                            <option value="Pending-External">Pending-External</option>
                        </lightning:select>
                    </div>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </aura:if>
 </aura:component>

The onclick functions for both the button and dropdown are like below

({
   openModel: function(component, event, helper) {
      var caseId = component.get('v.recordId');
      component.set("v.isOpen", true);
   },

  onChange: function (component, event, helper) {

       var dropdownSelection = component.find('select').get('v.value');
       var action = component.get("c.transferCase");

       action.setParams({caseId: component.get('v.recordId'), dept: dropdownSelection});
       action.setCallback(this, result => {
       .........

I am not sure how I can get the recordId (caseId) from the openModal function in to OnChange function. The component.get('v.recordId') is null in the OnChange.

1

You need to add force:hasRecordId to your component:

<aura:component implements="force:hasRecordId,flexipage:availableForRecordHome" ...
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.