【发布时间】:2022-11-11 06:53:10
【问题描述】:
创建费用卡必须填写的字段: 持卡人是联系方式 Months Expenses Applications 是一个自定义对象
创建费用卡时,如果在“日期”字段中输入的日期之前存在 Months Expenses Applications,则会创建一个新的费用卡,从现有的 Months Expenses Applications 中获取
如果在“日期”字段中输入的日期之前没有月份费用应用程序,您需要创建月份费用应用程序,然后创建一个费用地图,其中月份费用应用程序将创建一个新的月份费用应用程序
我试图创建一个“金额”“日期”“描述”等于输入参数的费用地图,但我不知道如何指定 MonthExpenseApplication__c
public static void createNewExpenseCard(Integer amount, Date createdDate, String description) {
Month_Expense_Application__c MonthApplication = [
SELECT Name, MonthDate__c
FROM Month_Expense_Application__c
WHERE MonthDate__c =: createdDate
];
if (MonthApplication != null) {
ExpenseCard__c exp = new ExpenseCard__c(
Amount__c = amount,
CardDate__c = createdDate,
Description__c = description,
CardKeeper__c = '0034x00001K7kGCAAZ'
);
exp.MonthExpenseApplication__c = [
SELECT MonthExpenseApplication__c
FROM ExpenseCard__c
WHERE MonthExpenseApplication__c =: MonthApplication.Id
].Id;
insert exp;
} else {
Month_Expense_Application__c monthApp = new Month_Expense_Application__c(
Balance__c = 1000,
MonthDate__c = createdDate,
Keeper__c = '0034x00001K7kGCAAZ'
);
ExpenseCard__c exp2 = new ExpenseCard__c(
Amount__c = amount,
CardDate__c = createdDate,
Description__c = description,
CardKeeper__c = '0034x00001K7kGCAAZ'
);
insert exp2;
}
}
【问题讨论】:
标签: salesforce apex lwc