• Sumit SF
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
Hello everyone,
I want to create a search mechanism where I can show all the contact related to an account, In that I want an extra column too. In that column I want to give an edit button.
I am able to create the search mechanism but not the edit button part.
Can anyone help me, below is my code.User-added image


Vs code for getting Data\


public with sharing class AccountContacts {
    @AuraEnabled(cacheable=true)
   public static List<Contact> fetchContact(String search){
        String searchkey='%'+search+'%';
      return [SELECT FirstName, LastName, Email, Phone, AM_Asgn_Office_Country_c__c  FROM Contact WHERE Account.Name LIKE :searchkey];
       
    }
}



Code for creating search mechanism

Html part

<template>
   
    <lightning-input placeholder="Enter the Account Name" onkeyup={handleinput}></lightning-input>
    <lightning-datatable key-field="id" data={ContactData} columns={columns}></lightning-datatable>


</template>

js part

import { LightningElement } from 'lwc';
import getContact from '@salesforce/apex/AccountContacts.fetchContact';

const cols = [

    {
        label : "FirstName",
        fieldName: "FirstName",
        type: 'text'
    },
    {
        label : "LastName",
        fieldName: "LastName",    
        type: 'text'
    },
    {
        label : "Email",
        fieldName: "Email",
        type:"Email"
    },
    {
        label : "Mobile",
        fieldName: "Phone",
        type:"Phone"
    },
   
    {
        label : "Office Country",
        fieldName: "AM_Asgn_Office_Country_c__c",
        type:"text"
    },
    {
        label : "Action",
        fieldName: "contactName",
        type:"url",
        typeAttributes: { label: { fieldName: 'Name' },  tooltip:"Name", target: '_blank'}
    }


];
export default class AccountContacts extends LightningElement
{
    ContactData;
    ContactError;
    columns=cols;
    key;

    handleinput(event)
    {
        this.key=event.target.value;
        this.fetchContactinfo();
    }
    fetchContactinfo()
    {
        getContact({search : this.key})
        .then(data=>
        {
            let resultdata=[];
            data.forEach(dataitem =>{
                let tempdata={};
                tempdata=Object.assign({},dataitem);
               
               
                //to hyperlink the contact itself
                tempdata.contactName = '/'+dataitem.Id;

                //to hyperlink the account
                // if(dataitem.Account){
                //     tempdata.accountName = '/'+dataitem.AccountId;
                //     tempdata.accName=dataitem.Account.Name;
                // }
               
                resultdata.push(tempdata);
            });
            console.table(resultdata);
            this.ContactData=resultdata;
           
        })
        .catch(error=>
            {
                this.ContactError=error;
        })
    }

}
Hi all,
I was wondering if someone cloud help me figure this out. 
I have a custom object called "OrganisationRoleName__c"
With the following text field called "RoleName__c" 
Checkbox called ''Istrue__c"
I have a Static List of words ie 
  • Hamptom
  • Avenue
  • Road 
  • Community 
On the "OrganisationRoleName__c" object I have records with the following values:
  • New Hamport Place
  • People Avenue
  • Gregory Road
  • Developer Community
Scenario
If a record is created and RoleName__c name substring is contained in the Static List set strue__c= true.

Hope this makes sense.
Thanks in advance.




 
Hi All,
Getting below error when inserting 100 records
System.LimitException: Apex CPU time limit exceeded

String ob= Schema.getGlobalDescribe().get('Opportunity').getDescribe().getRecordTypeInfosById().get(opp.RecordTypeId).getName();
if(ob=='oops'){
//updating one field
}

Any alternate way to get recordtype name ? or other way to write above code ?
 
Hi Team,

appreciate your help,please help me in completing the test class for below
 
public with sharing class saveCaseType {
     
     @AuraEnabled
     Public  static ERT_Case_Type__c  savecasetype(string level1,string level2,string level3,string caseid){
     ERT_Case_Type__c obj=new ERT_Case_Type__c();
     Obj.Id =caseid;
     Obj.Level_1__c=level1;
     Obj.Level_2__c=level2;
     Obj.Level_3__c=level3;
     Insert obj;
     return obj;
     }
    
    
    

}

Thanks in Advance
Carolyn​​​​​​​