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
Timmy AhluwaliaTimmy Ahluwalia 

Record Edit Form

Hi,
Created a datatable to update the multiple records but this is not supported on the Mobile. 

So I  am iterating a record edit form and want to change the status of selected records to active.
How can i get this done.
Thanks
Best Answer chosen by Timmy Ahluwalia
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Timmy

Try this out :

<aura:iteration items="{!v.myList}" var="contact">
  
                <lightning:recordEditForm aura:id="form"
                                          recordId="{!contact.Id}"  
                                          objectApiName="CampaignMember"
                                           onload="{!c.handleOnload}"
                                            onsubmit="{!c.handleOnSubmit}"    
                                          class="slds-card__body_inner">
 
                    <div class="slds-box slds-theme_default">
                        <lightning:outputField fieldName="Name" />
                        <lightning:outputField fieldName="CompanyOrAccount" />
                        <lightning:outputField fieldName="Status"  />
                        <lightning:input type="checkbox" aura:id ="checkbox" default= "false"  value=“{!contact.isSelected}”/>
                        
                    </div>
                </lightning:recordEditForm>
         
                <br />
            </aura:iteration>

<lightning:button label="Attended" type= "submit" onclick= "{!c.handleOnSubmit}"  />
                        <lightning:button label="Declined" type= "submit" />


COntroller
 handleOnSubmit : function(component, event, helper) {
        event.preventDefault();
Var myList = component.get(“v.myList”) || [];
Var selectedRecords = [];

for(var index=0;index<myList.length;index++){
if(myList[index].isSelected){
Var selectedContact = myList[index];
selectedContact. Status = “Attended”;
selectedRecords.push(selectedContact);
}
}

console.log(‘selectedRecords’+selectedRecords);
}


The selectedRecords contains the updated status contact records.

Cheers!!!!

All Answers

Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Timmy 

Can you post your current code status so that I can look into it to help you out.

Cheers!!!
Timmy AhluwaliaTimmy Ahluwalia
Hi,
The code is attached. Thanks
<aura:iteration items="{!v.myList}" var="contact">
  
                <lightning:recordEditForm aura:id="form"
                                          recordId="{!contact.Id}"  
                                          objectApiName="CampaignMember"
                                           onload="{!c.handleOnload}"
                    						onsubmit="{!c.handleOnSubmit}"	
                                          class="slds-card__body_inner">
 
                    <div class="slds-box slds-theme_default">
                        <lightning:outputField fieldName="Name" />
                        <lightning:outputField fieldName="CompanyOrAccount" />
                        <lightning:outputField fieldName="Status"  />
                        <lightning:input type="checkbox" aura:id ="checkbox" default= "false"  />
                        <lightning:button label="Attended" type= "submit" onclick= "{!c.handleOnSubmit}"  />
                        <lightning:button label="Declined" type= "submit" />
                    </div>
                </lightning:recordEditForm>
         
                <br />
            </aura:iteration>
COntroller
 handleOnSubmit : function(component, event, helper) {
        event.preventDefault();
     var select = component.find("checkbox");
         var i =0;
         for(i=0; i<select.length; i++){
             if(i= "true"){
                 var fields = event.getParam("fields");
       			 fields["Status"] = 'Attended';  
           
             }
         }
         console.log(select);*/

 
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Timmy

Try this out :

<aura:iteration items="{!v.myList}" var="contact">
  
                <lightning:recordEditForm aura:id="form"
                                          recordId="{!contact.Id}"  
                                          objectApiName="CampaignMember"
                                           onload="{!c.handleOnload}"
                                            onsubmit="{!c.handleOnSubmit}"    
                                          class="slds-card__body_inner">
 
                    <div class="slds-box slds-theme_default">
                        <lightning:outputField fieldName="Name" />
                        <lightning:outputField fieldName="CompanyOrAccount" />
                        <lightning:outputField fieldName="Status"  />
                        <lightning:input type="checkbox" aura:id ="checkbox" default= "false"  value=“{!contact.isSelected}”/>
                        
                    </div>
                </lightning:recordEditForm>
         
                <br />
            </aura:iteration>

<lightning:button label="Attended" type= "submit" onclick= "{!c.handleOnSubmit}"  />
                        <lightning:button label="Declined" type= "submit" />


COntroller
 handleOnSubmit : function(component, event, helper) {
        event.preventDefault();
Var myList = component.get(“v.myList”) || [];
Var selectedRecords = [];

for(var index=0;index<myList.length;index++){
if(myList[index].isSelected){
Var selectedContact = myList[index];
selectedContact. Status = “Attended”;
selectedRecords.push(selectedContact);
}
}

console.log(‘selectedRecords’+selectedRecords);
}


The selectedRecords contains the updated status contact records.

Cheers!!!!
This was selected as the best answer
Timmy AhluwaliaTimmy Ahluwalia

Hi Syed,
I am using your code but the isSelected is not catching any value and it comes out of the loop.
i have entered the console log command to check. Please update.
Thanks
Timmy AhluwaliaTimmy Ahluwalia
Hi,
When we check the  checkbox and click Attended button then the controller is checking if the value of selected chek box is selected, if selected then the Status field should be changed to Attended.
But it look that the check box is not binding to the record, may be it need some binding.
I can't figure out this binding.
Thanks
 
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Timmy

Could you please change your attribute declaration to this : 

<aura:attribute name = "myList"  type = "Object[]"/>

Then try to debug,if still it doesn't work please attach your complete code so that I can help you.

Cheers!!!
Timmy AhluwaliaTimmy Ahluwalia
Thanks.
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Timmy

Didi it work??
 
Timmy AhluwaliaTimmy Ahluwalia
Hi Syed,
Your code worked the problem was with the lightning input 
  <lightning:input type="checkbox" aura:id ="checkbox" default= "false"  value=“{!contact.isSelected}”/>
instead of this i changed to the  ui button and it worked.
 <ui:inputCheckbox text="{!contact.Id}" aura:id="boxPack" value="" />
Thanks