You need to sign in to do that
Don't have an account?
SV M
Add opportunity to a specific account
Hi,
I would like to add opportunities whose Stage and Type is New Opportunity and New Business. I have added a new account record and these opportunities should be linked to the newly created account record.
//Batch Class
global class BatchForAddingOpps implements Database.Batchable<sObject> {
List<Opportunity> oppList {get;set;}
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator([SELECT Name, Type, StageName, CreatedDate
FROM Opportunity
WHERE Type = 'New Business' AND StageName = 'New Opportunity']);
}
global void execute(Database.BatchableContext BC, List<Opportunity> oppList) {
List<Opportunity> newList = new List<Opportunity>();
for(Opportunity opp : oppList) {
opp.StageName = 'Closed Lost';
}
update oppList;
System.debug('newList'+oppList);
}
global void finish(Database.BatchableContext BC) {
}
}
I've got the opportunities but unable to add these opportunities to newly created account record...Can someone help me achieve this...
Thanks in advance.
I would like to add opportunities whose Stage and Type is New Opportunity and New Business. I have added a new account record and these opportunities should be linked to the newly created account record.
//Batch Class
global class BatchForAddingOpps implements Database.Batchable<sObject> {
List<Opportunity> oppList {get;set;}
global Database.QueryLocator start(Database.BatchableContext BC) {
return Database.getQueryLocator([SELECT Name, Type, StageName, CreatedDate
FROM Opportunity
WHERE Type = 'New Business' AND StageName = 'New Opportunity']);
}
global void execute(Database.BatchableContext BC, List<Opportunity> oppList) {
List<Opportunity> newList = new List<Opportunity>();
for(Opportunity opp : oppList) {
opp.StageName = 'Closed Lost';
}
update oppList;
System.debug('newList'+oppList);
}
global void finish(Database.BatchableContext BC) {
}
}
I've got the opportunities but unable to add these opportunities to newly created account record...Can someone help me achieve this...
Thanks in advance.
if you want to associate an account with opportunity.
update accountid on opportunity with id of account