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
Akhil Katkam 5Akhil Katkam 5 

How to display only one specific record value with aura iteration for table view

Hi Developer Community,

i have a requriement for my task ,

i want to display a custom object record using table slds attribute ,

but i want to display only one particular record from that custom object 

how to do that , i have already written some code , but it is displaying all records

my code: 

 

.cmp: 

<aura:attribute name="CompetingProduct" type="ciboostc1501__Competing_Product__c" />
      <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
  	  <lightning:card title="Personas">
      <aura:set attribute="body">
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
   <thead>
    <tr class="slds-text-title_caps">
      <th scope="col">Personas</th>
      <th scope="col">Key Message</th>
       </tr>
         </thead>
           <tbody>
    <aura:iteration items="{!v.CompetingProduct}" var="comp">
         <tr scope="row">
             <td>{!comp.ciboostc1501__Persona1__c}</td>      
             <td>{!comp.ciboostc1501__Key_message_1__c}</td>  
        </tr>
     </aura:iteration>
         </tbody>
          </table>
          </aura:set>
    </lightning:card>

---------------------------------------------------------------------------------------------------

controller.js :

({
  doInit: function(component, event, helper) {
    var action = component.get("c.getDetails");
    action.setCallback(this, function(data) {
      component.set("v.CompetingProduct", data.getReturnValue());
      console.log(data.getReturnValue());
    });
    $A.enqueueAction(action);
  }
})

------------------------------------------------------------------------------------------------

apex class :

public class competingclass {
@AuraEnabled
public static List<ciboostc1501__Competing_Product__c> getDetails(){
  return [SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c];
}

}
 

can anyone please tell me how to display only one particular record 

Thanks in Advacnce

CharuDuttCharuDutt
Hii Akhil KatKam
Try Below Code
EXAMPLE:

public class competingclass {
@AuraEnabled
public static List<Account> getDetails(){
List<Account> lst = [SELECT id,name,phone FROM Account where name ='Edge Communications'];
      return lst;
  }
}


Please Mark It As Best Answer If It Helps
Thank You!
Suraj Tripathi 47Suraj Tripathi 47
Hi Akhil,
Greetings!

If you want to display any one custom record, then use this SOQL query-
[SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c LIMIT 1]

Otherwise, for a particular single record, you have to add where clause to your SOQL to identify the particular record.
For example record Name,
[SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c WHERE Name  = 'ExampleName']
or Maybe identify by Id-
[SELECT ciboostc1501__Persona1__c,ciboostc1501__Key_message_1__c FROM ciboostc1501__Competing_Product__c WHERE Id = 'xxxxxxxxxxxxxxxxxx'];
If you find your Solution then mark this as the best answer. 
Thank you!
Regards,
Suraj Tripathi
Akhil Katkam 5Akhil Katkam 5
Thanks Charu Dutt and Suraj tripathi , you both helped me with the solution
Suraj Tripathi 47Suraj Tripathi 47
Hi Akhil,
Glad to be of help.
Please mark the answer as the best answer to keep this community clean and for other help.
Thanks and Regards
Suraj Tripathi.
CharuDuttCharuDutt
Hii Akhil Katkam 

Please Close Your Query By Marking It As Best Answer 

Thank You!