Triggers Salesforce触发器-从触发器记录传递值

Triggers Salesforce触发器-从触发器记录传递值,triggers,salesforce,Triggers,Salesforce,这里的目标–从触发器中的记录中提取account__r.id,并将值添加到每个for循环的列表中 代码示例一 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 WHE

这里的目标–从触发器中的记录中提取account__r.id,并将值添加到每个for循环的列表中

代码示例一

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);
代码示例二

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)显示account对象中的id为空

当然,1需要对触发器中的每个记录进行查询。没有样式点。 这预示着另一个重要而令人烦恼的问题

在after delete触发器的上下文中,即使是#1也不起作用,因为您无法查询数据库中已删除的数据


有人能提出另一种方法吗?我遗漏了什么?

您可能会在销售人员中得到关于这个问题的最佳回答谢谢,安德鲁。你可能是对的!