当父运行逻辑

时间:2018-02-14 10:02:45

标签: salesforce apex

嗨我有以下代码,我从一个孩子那里拿ID,然后在父母身上看一样。然后,当我的条件通过时,我想要更新我孩子的孩子

我的代码:

list<Stripe_Customer__c> Clist = new list<Stripe_Customer__c> 
                                                ([Select Id, Distributor__c, FBO_Name__c, FLP_Email__c, Language_Preference__c,
                                                (select Id from Stripe_Invoices__r where Attempt_Count__c = 1 
                                                                AND Paid__c = false
                                                                AND Missed_Payment_Email1__c = FALSE
                                                                AND Invoice_Date__c = TODAY AND Live_Mode__c = TRUE 
                                                                AND Attempted__c = TRUE limit 1) 
                                                                from Stripe_Customer__C
                                                where Id IN (select Stripe_Customer__c from Stripe_Invoice__c 
                                                                where Attempt_Count__c= 1
                                                AND Paid__c = false 
                                                AND Invoice_Date__c = TODAY
                                                AND Live_Mode__c = TRUE 
                                                AND Attempted__c = TRUE
                                                AND Missed_Payment_Email1__c = FALSE)]);

        for(Stripe_Customer__c cid : Clist){
            Dlist.add(cid.Distributor__c);
        }

        List<account> Alist = new List<account>([ SELECT name, Email_FLP_com__c, Language_Preference__c ,
                                                 (select Distributor__c from Stripe_Customers__r where Provision_Status__c='active')
                                                 from account where Distributor_ID__c IN: Dlist]);

for(Account c:Clist){

//我的代码 }

c=Stripe_Customer__c;
{
c.Stripe_Invoices__r[0].Missed_Payment_Email1__c = true;
            c.Stripe_Invoices__r[0].Missed_Email1_Date__c = system.today();
            c.Stripe_Invoices__r[0].Email_Response__c = resultBodyGet;
            InUpdate.add(c.Stripe_Invoices__r[0]);
}
update InUpdate;

现在想更新List InUpdate = new List();它位于Lookup with Account和Child with Stripe_Customer__c

请帮忙

1 个答案:

答案 0 :(得分:0)

当您致电&更新InUpdate&#39;时,您的代码中已经在进行此类更新。最后 - 只需确保您在&#39; Clist&#39;中查询所需的所有字段。并做出改变。

除此之外,立即弹出的是你无法循环播放的克里斯特&#39;在Account循环中,因为这些是不同的对象。另外,就像现在写的那样,看起来你在for循环中进行更新这是一个不好的做法,你应该避免这样做。您应该查看有关批量化代码的开发人员指南。