global without sharing class AccountWebService {
|
|
// 無効のAccountの所有者をBatch Userにする
|
WebService static String toBatchOwner(String hpid) {
|
|
List<Account> accList = [select Id from Account
|
where (Id = :hpid or ParentId = :hpid or Parent.ParentId = :hpid)
|
and Is_Active_Formula__c = '无效'];
|
|
if (accList.size() > 0) {
|
try {
|
// 所有者更新
|
for (Account acc : accList) {
|
acc.OwnerId = '00510000000fSYI';
|
}
|
update accList;
|
|
// チームメンバー削除
|
List<AccountTeamMember> atm = [select Id from AccountTeamMember where AccountId in :accList];
|
if (atm.size() > 0) delete atm;
|
|
} catch (Exception e) {
|
return e.getMessage();
|
}
|
}
|
|
return 'OK';
|
}
|
|
}
|