此处的目标 - 从触发器中的记录中提取account__r.id,并将值添加到每个for循环的列表中...
CODE SAMPLE ONE
if (trigger.isinsert) {
for (loan__c oloan : trigger.new){
system.debug(oloan);
Loan__c loanintrigger = new loan__c();
loanintrigger = [ SELECT loan__c.name,account__r.id from loan__c WHERE loan__c.id = : oloan.id];
Account a = new account ();
a.id = loanintrigger.account__r.id;
// debug to test insertion of value directly from trigger object.....
system.debug(a.id);
CODE SAMPLE TWO
if (trigger.isinsert) {
for (loan__c oloan : trigger.new){
system.debug(oloan);
Account a = new account ();
a.id = oloan.account__r.id;
// debug to test insertion of value directly from trigger object.....
system.debug(a.id);
所以...触发一个运行并完成其分配。由于“缺少参数”,触发器2失败。 - system.debug(a.id)显示帐户对象中的id为null。
当然,这预示了另一个重要而棘手的问题......
在删除后触发器的上下文中,甚至#1都不起作用,因为您无法在数据库中查询已删除的数据!
有人可以建议替代方法吗?我错过了什么?