【发布时间】:2019-12-03 21:49:24
【问题描述】:
更新问题:
所以我创建了一个可调用的变量/方法,其中流程传递以下参数:
public static void updateAccountOwner(List<TransferDetail> transferDetails) {
for(TransferDetail td : transferDetails) { //THIS IS WHERE I AM COMPLETELY UNSURE ABOUT, AND I WAS TOLD A MAP WOULD BE BETTER TO BULKFY?
for(Account a : td.accounts){
// Account a = new Account(Id = td.a.accountId, AccountOwner__c = td.a.newOwnerId);
// accounts.add(a);
// }
}
}
public with sharing class Request{
@InvocableVariable
public List<Account> accounts;
@InvocableVariable
public String newAccountOwnerName;
@InvocableVariable
public String oldAccountOwnerName;
}
因此,此帐户列表中的每个帐户都有自己的机会。但是列表中的每个帐户都将更新为同一新所有者,并且每个机会都将转移给同一所有者
我创建了一个闪电流,其中我获得了基于用户输入的标准/信息的帐户列表。我正在尝试获取此帐户列表并更新其所有者值以及列表中每个帐户的所有子联系人。所以它是列表中的列表。我知道我必须为此使用地图,但我不确定我做错了什么/如何开始。这是我所拥有的:
public with sharing class LPP_UpdateOwner {
public static void updateAccountOwner(List<List<Account>> accounts, newOwnerId){ //accounts would be the input list from the flow and is a list/colection of accounts that the flow queried. newOWNERID would be the name the user typed in the flow
List<Account> aUpdated = new List<Account>(); //should this be a map??
for( Account a: accounts){
a.AccountOwner__c = newOwnerId;
aUpdated.add(a)
}
update aUpdated;
Map<Id, Opportunity> oppList = new Map<Id, Opportunity>([SELECT Id, Name from Opportunity where AccoundId IN :accounts.keySet() and Stage !='Closed Won']);
List<Opportunity> oppToUpdate = new Opportunity();
for (Opportunity opp :oppList.values()){
opp.OwnerId = aUpdated.AccountOwner__c ? not sure what to put here(opportunity owner and account owner ha to be same, which is newNameId
oppToUpdate.add(opp);
}
update OpptoUpdate;
所以我不确定这是否正确。基本上,我正在尝试使用提供的新名称更新所有帐户和每个帐户的机会。此外,我尝试使用 Maps 的原因是为了避免 CPU 时间限制,因为在流程和流程构建器中执行此操作会导致 CPU 超时错误。 谢谢
【问题讨论】:
-
您是说传入此方法的每个帐户都设置为同一所有者吗?我问是因为您声明了在
it is a list within a list中传递的帐户,但您只传递了一个所有者 ID,因此在您当前的设置中,所有这些都将设置为同一所有者。 -
@nerdybeast 是的。所以我会有一个账户列表,所有账户都归约翰所有。我将通过该帐户列表和名称,让我们说马克。该列表中的所有帐户都需要转移以进行标记。此外,例如,列表中的每个帐户都有机会。这些机会中的每一个现在都需要由来自 John 的 Mark 拥有
-
我遇到的另一个问题是@invokable 方法中只能使用一个输入参数。所以我可以将帐户列表或名称传递给班级
-
我在下面留下了一个答案,我认为这就是你所追求的
标签: apex