Этот SOQL дает мне Account.Maintenance_Contact__r.id (003C000002M6kiDIAR)
Select ID, owner.id, owner.isactive,
Master_Opportunity__c, Internal_Start_cycle_days_ROPP__c,Invoice_cycle_days_ROPP__c,
**Account.Maintenance_Contact__r.id**
from Opportunity
where Master_Opportunity__c = null
and Account_Record_Type__c != 'Personal Use Accounts'
and Renewal_Stage__c in ('Pending PO','Pending SLSA','Pending OEM')
and Invoice_cycle_days_ROPP__c = NEXT_MONTH ]
, но когда я добавляю его в Apex, он дает мне этот Account.Maintenance_Contact__r.id "001C0000013yu9QIAQ", а не идентификатор контакта.
public class Oppjob_Task_PORequired_cls {
public void createTaskforOpp() {
List<Opportunity> oppList = [Select ID, owner.id, owner.isactive,
Master_Opportunity__c, Internal_Start_cycle_days_ROPP__c,Invoice_cycle_days_ROPP__c,
Account.Maintenance_Contact__r.id
from Opportunity
where Master_Opportunity__c = null
and Account_Record_Type__c != 'Personal Use Accounts'
and Renewal_Stage__c in ('Pending PO','Pending SLSA','Pending OEM')
and Invoice_cycle_days_ROPP__c = NEXT_MONTH
and id ='006C000001CSbQIIA1'];
List<Task> taskList = new List<Task>();
system.debug('oppList' + opplist);
For(Opportunity opp : oppList) {
if(opp.Owner.isActive == true) {
Task newTask = new Task(
WhatId = opp.Id,
OwnerId = opp.OwnerId,
Team__c = 'PreSales Support',
// Task_Type__c = 'RMT Follow Up',
WhoID = opp.Account.Maintenance_Contact__r.id,
//WhoID = '003C000002M6kiDIAR',
ActivityDate = system.today().adddays(3) ,
Subject = 'PO Required Follow-up',
Description = 'Follow up for customer PO');
taskList.add(newTask);
}
}
system.debug('TaskList:' + tasklist.size());
if (tasklist.size()>0){
insert taskList;
}
}
}