我目前遇到一个问题,希望这里有人可以帮助我。我当然也希望这是问它的正确地方。
我正在尝试在触发事件时创建具有相应发票行记录的自定义发票记录。我已经有一些逻辑来收集 JS 中选定行的 ID。
我已经能够创建发票记录(使用 LDS)和发票行记录(使用 Apex),但似乎无法传递发票行记录的发票 ID。我知道我能够创建记录,因为当我使用硬编码的发票 ID 测试它时它可以工作。
是否可以将 List 和 String 的多个参数传递给 LWC 中的 Apex 方法?
我将不胜感激任何帮助。提前致谢!
JS
selectedRowsEvent(event) {
...some codes here...
this.selectedRecords = Array.from(conIds);
}
handleSave() {
**invId;**
...some codes here...
createRecord(recordInput)
.then(invoice => {
**this.invId = invoice.Id;**
**createInvLines({ lstConIds : this.selectedRecords, invoiceId : this.invId})**
}).catch(error => {
...some codes here...
});
}
控制器
@AuraEnabled
public static void createInvLines(list<Id> lstConIds, string invoiceId){
if(lstConIds.size() > 0){
List<OpportunityLine__c> oppLst = new List<OpportunityLine__c>([SELECT Id, Description__c FROM OpportunityLine__c WHERE Id = :lstConIds]);
try {
List<InvoiceLine__c> lstInvLinesToInsert = new List<InvoiceLine__c>();
for(OpportunityLine__c idCon : oppLst) {
lstInvLinesToInsert.add(new InvoiceLine__c(**InvoiceId__c = invoiceId**, Description__c = idCon.Description__c));
}
if(!lstInvLinesToInsert.isEmpty()) {
insert lstInvLinesToInsert;
}
}
catch(Exception ex) {
throw new AuraHandledException(ex.getMessage());
}
}
}