You need to sign in to do that
Don't have an account?
srikanth darbha 11
LWC Apex Imperative type Callout
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?
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?
you can try the below :
JS
you apex class :
Referenced from : https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.apex
Please mark as best answer if it solves your issue.
Thanks!
I dont want to use wiring as i dont want the results to be cacheable. I want to user apex imperative call, Can anyone please help me how to pass a return value using apex imeprative call, not using wiring.