You need to sign in to do that
Don't have an account?
AL
Salesforce to Salesforce Auto-Accept Opportunities
I have a salesforce to salesforce connection and I would like to be able to send both the opportunity and related opportunity products without having to manually accept them in the target org. According to salesforce documentation, if the auto-accept on opportunities is turned on, then opportunity products can't be shared.
Is there a way to bypass this with an apex batch job perhaps (mass auto accept)?
Thank you
Is there a way to bypass this with an apex batch job perhaps (mass auto accept)?
Thank you
May I suggest you please check with below link from the success community which will point you in the right direction.
- https://success.salesforce.com/answers?id=90630000000gsg2AAA
Hope this helps.Please mark this as solved if the information helps.
Thanks,
Nagendra
trigger OppOwnerUpdate on Opportunity (after insert) {
if(trigger.isinsert){
//opportunity IDs needed to update the owner value. These id records are shared by published company
set<id> FinalOptyIds = new set<id>();
//Collect the list of opties which are created/updated by partnernetwork companY
List<PartnerNetworkRecordConnection> ConListOpty = new List<PartnerNetworkRecordConnection>(
[select Id, ConnectionId, PartnerRecordId, LocalRecordId from PartnerNetworkRecordConnection
where LocalRecordId in :Trigger.newmap.keyset() AND (Status ='Sent' OR Status = 'Received') AND ConnectionId='007499281']);
//system.debug('ConListOpty-----' + ConListOpty);
//Collect the opty ids
if(!ConListOpty.isEmpty()){
for(PartnerNetworkRecordConnection op : ConListOpty){
if(op.LocalRecordId != null){
FinalOptyIds.add(op.LocalRecordId);
}
}
system.debug('FinalOptyIds-----' + FinalOptyIds);
// Query the available opties which are shared by partner network
list<opportunity> optyList = [select id,owner.id from opportunity where id IN:FinalOptyIds];
list<opportunity> optyListFinal = new list<opportunity>();
//TODO: Opportunity Owner Move this hardcoding id to custom settings. change for each org when deploying
Opportunity oppOwner = [select id from Opportunity where OwnerID = '00520000003p1tO'];
//system.debug('optyList-----' + optyList);
for(opportunity optOwner: optyList ){
if(optOwner.Ownerid != null){
opportunity opty = new opportunity();
opty.id = OptOwner.id;
opty.OwnerId = optOwner.id;
optOwner.id = '00520000003p1tO';
optyListFinal.add(optOwner);
//system.debug('Done----');
}
}
//TODO: Move this hardcoding id to custom settings. change for each org when deploying
Pricebook2 priceb = [select id from Pricebook2 where id = '341393019'];
//system.debug('optyList-----' + optyList);
//updating the shared created opty owners with Opportunity product
for(opportunity opt: optyList ){
if(opt.Pricebook2.id != null){
opportunity opty = new opportunity();
opty.id = opt.id;
opty.Pricebook2ID = opt.Pricebook2.id;
optyListFinal.add(opty);
//system.debug('Done----');
}
}
update optyListFinal;
}
}
}