You need to sign in to do that
Don't have an account?

lightning web component Pass Javascript array of object to APEX and typecase it to APEX Class
HI I am building a Lightning Web Component (LWC)
I did all the edits and I have an array with ID and Perecentage(custom field). The array is marked with @track in the js file.
I am lost on how I can convert this array in APEX to a LIST so that I can update the data in APEX.
Thanks
I did all the edits and I have an array with ID and Perecentage(custom field). The array is marked with @track in the js file.
I am lost on how I can convert this array in APEX to a LIST so that I can update the data in APEX.
Thanks
In the Apex Class use JSON parser and iterator and create a list of objects of your custom object type
All Answers
In the Apex Class use JSON parser and iterator and create a list of objects of your custom object type
i want result like this with lwc(https://rajvakati.com/2018/02/18/usage-of-lightningduallistbox/),
can anyone tell what i m doing wrong in this code below is the code
js file
import { LightningElement,track,wire,api} from 'lwc';
import getopp from '@salesforce/apex/WrapperclassForOpportunity.getopp';
export default class MultiPickList1 extends LightningElement {
@api contactlist=[];
@wire(getopp) opplist({error,data}){
if (data) {
this.contactlist = data[0].conlist;
alert('this.contactlist@@ '+ JSON.stringify (data[0].conlist) );
alert('contactlist:'+this.contactlist);
}
}
}
html file
<template>
<lightning-card title="Multi select Picklist ">
<lightning-dual-listbox
name="languages"
label="Select Record"
source-label="Available Contact Record"
selected-label="Selected Contacted Record"
options={contactlist}
onchange={handleChange}>
</lightning-dual-listbox>
</lightning-card>
</template>
wrapper class
public class WrapperclassForOpportunity {
@AuraEnabled(cacheable=true)
public static List<payWrap> getopp(){
List<payWrap> accWrapperList = new List<payWrap>();
opportunity getopp=[select id, accountid,closedate,stagename from opportunity where id=:'0062v00001TDCVoAAP'];
system.debug(getopp);
account acc= [select id, name from account where id=:getopp.accountId];
system.debug(acc);
list<contact> conlist1=new list<contact>();
conlist1=[select name from contact where accountid=:acc.id];
if(!conlist1.isEmpty()){
payWrap myWrap= new payWrap();
mywrap.conlist=conlist1;
accWrapperList.add(myWrap);
}
system.debug(accWrapperList);
return accWrapperList;
}
public class payWrap{
@AuraEnabled
public List<Contact> conlist{get;set;}
}
}
may be console.log the result. Also add a else if (error) in your wire and see if there are any issues there..
Side note: In your apex, why cant you combine the opportunity, Account and contact query all in one