"Invalid foreign key relationship: Opportunity.opportunitylineitem"
How should I be referencing this field?
global class OpOwnerOldService_Scheduled Implements Schedulable
{
global void execute(SchedulableContext sc)
{
sendEmailtoOppOwner();
}
public void sendEmailtoOppOwner()
{
List<Opportunity> listOpportunity = new List<Opportunity>();
listOpportunity = [SELECT Id, OwnerId FROM Opportunity WHERE Id In (SELECT OpportunityId FROM OpportunityLineItem WHERE Product2.Make_unavailable_for_opps_and_proposals__c = TRUE)];
for(Opportunity opp : listOpportunity)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(opp.OwnerId);
mail.setReplyTo('glenn.daly@live.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('Historic Service attached to current opportunity : ');
mail.setPlainTextBody(opportunity.Id +' has been created.');
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
update listOpportunity;
}
}
답변 1개
This Answers Community is focused on configuration and design questions. It would be better to post this in the developer community or stackexchange for the proper response:
https://developer.salesforce.com/forums
http://salesforce.stackexchange.com/
Please mark best answer to close this thread and make community clean. Thanks!