• srikanth darbha 11
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi Everyone,

I have function inside JS file, where i am trying to invoke a apex imperative call as below-
getdlcontactscount({dls:str3})
.then(res => {
if (res.data) {
for(var i=0; i<data.length; i++) {
console.log('id=------' + data[i].TempValue__c);
this.refreshTable = data[i].TempValue__c;
}
this.error = undefined;
}

The request is hitting the apex method as below-

List<String> st= dls.split(';');
List<Contact> countval= new List<Contact>();
System.debug(LoggingLevel.INFO,'st value-----------'+st);
List<Contact> contactfinalids=new List<Contact>();
List<contact> lstcon=[Select Id,Email,Distributions_List_Assigned_To__c FROM Contact where email!=null];
for(String s:st)
{
for(Contact ct:lstcon){
if(ct.Distributions_List_Assigned_To__c!=null && (ct.Distributions_List_Assigned_To__c).contains(s.trim()))
contactfinalids.add(ct);
}
}
System.debug('contactfinalids-----------'+contactfinalids);
//countval.add(contactfinalids.size());
Contact c = new Contact();
c.TempValue__c=contactfinalids.size();
countval.add(c);
System.debug('contactfinalids----countval-------'+countval);
return countval;

I am getting the output in apex class, but when i am checking at the JS function the console statement itself is not getting printed
Can someone please help me on how to return values from apex imeprative calls , i.e how can i send a Integer value or a string value? 
 
Hi Guys,

I want to pass recordID from a LWC Component to a apex class in connectedCallback method.,But sommehow i am getting the value as null inside the class, Not able to understand where i am going wrong,
Can anyone please help me out .

export default class AddContacToDl extends LightningElement {
connectedCallback() {
var rcid= this.recordId;
console.log('rcid---beofre----'+rcid);
getSelectedDLDetails({contactIDname:this.rcid})
.then(data => {
console.log('data------'+data);
for(var i=0; i<data.length; i++) {
console.log('id=seleccted' + data[i]);
this.distvalue = [...this.distvalue ,{value:data[i], label: data[i]}];
}
this.error = undefined;
}).catch(error=>{
this.error = error;
this.distvalue = undefined;
})
}

Apex class-

@AuraEnabled
public static List<String> getSelectedDLDetails(String contactIDname)
{
System.debug(LoggingLevel.info,'ID value------'+contactIDname);
Hi Everyone,

I have function inside JS file, where i am trying to invoke a apex imperative call as below-
getdlcontactscount({dls:str3})
.then(res => {
if (res.data) {
for(var i=0; i<data.length; i++) {
console.log('id=------' + data[i].TempValue__c);
this.refreshTable = data[i].TempValue__c;
}
this.error = undefined;
}

The request is hitting the apex method as below-

List<String> st= dls.split(';');
List<Contact> countval= new List<Contact>();
System.debug(LoggingLevel.INFO,'st value-----------'+st);
List<Contact> contactfinalids=new List<Contact>();
List<contact> lstcon=[Select Id,Email,Distributions_List_Assigned_To__c FROM Contact where email!=null];
for(String s:st)
{
for(Contact ct:lstcon){
if(ct.Distributions_List_Assigned_To__c!=null && (ct.Distributions_List_Assigned_To__c).contains(s.trim()))
contactfinalids.add(ct);
}
}
System.debug('contactfinalids-----------'+contactfinalids);
//countval.add(contactfinalids.size());
Contact c = new Contact();
c.TempValue__c=contactfinalids.size();
countval.add(c);
System.debug('contactfinalids----countval-------'+countval);
return countval;

I am getting the output in apex class, but when i am checking at the JS function the console statement itself is not getting printed
Can someone please help me on how to return values from apex imeprative calls , i.e how can i send a Integer value or a string value?