function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alaschgarialaschgari 

Salesforce to Salesforce: Opportunity is not auto-accepted

Hey folks,

 

As I forward my opportunity from org A, it is not accetped automatically by org B, even if Auto-Accept is enabled. What's the problem?

 

Thanks!

Josh

Best Answer chosen by Admin (Salesforce Developers) 
JFraileJFraile

Hi alaschgari,

 

To view this link try adding a field to the opportunity related list on the account page. The field is called Sent Connection Name.
When you have added this field, you will see it has a link called manage connections. Clicking on this link will share the opportunity as a child of the account, so probably auto-acceptance won't work.

 

It seems to be a problem with child auto-acceptance process... When auto-acceptance did work, the opportunity was successfully related to the account? If not, then you should check the opportunity complies all the criteria for child auto-acceptance to work (https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_auto_accept.htm&language=en_US). If yes, there you go!

All Answers

JFraileJFraile

Hi.

 

Check if there is a vaidation rule problem

"If an error occurs when accepting a record, see the Connection History for details. The Connection History lists validation rule errors for manually and automatically accepted records; it doesn't include system errors." (https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_lead_inbox.htm&language=en_US)

alaschgarialaschgari

Hey,

 

thanks for the quick reply. Unfortunately the connection history is clean. No error listed... Any other ideas?

 

Josh :-)

JFraileJFraile

Hi.

 

If you can manually accept the record it means there si no problem with any code/validations/database conflicts.

 

Then, if the record is a child of another one, I'd review the following criteria https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_auto_accept.htm&language=en_US

alaschgarialaschgari

The account related to the opportunity is already shared.

I have a clue what the problem could be: I have multiple pricebooks in the target org. Could this be the reason why an auto-acceptance of the opportunity is not possible?

How could I still make it work?

JFraileJFraile

As far as I know, pricebooks are related to opportunity product acceptance process. But just to be sure, try to share an opportunity with no pricebook set, and see if auto-acceptance works. There is good info here https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_assign_records.htm&language=en_US

 

When you share the opportunity, are you using the forward button from the opportunity detail page, or the 'manage connections' from the opportunity related list on the account detail page?

alaschgarialaschgari

Hi JFralle,

thanks for the support so far.

 

I actually use a trigger to forward the opportunity without defining a pricebook:

 

		            for (Opportunity newOpportunity : localOpportunitys) { 
		  
		                if (sharedAccountSet.contains(newOpportunity.AccountId)) { 
		                   
		                    PartnerNetworkRecordConnection newConnection = 
		                      new PartnerNetworkRecordConnection( 
		                          ConnectionId = networkId, 
		                          LocalRecordId = newOpportunity.Id, 
		                          SendClosedTasks = false, 
		                          SendOpenTasks = false, 
		                          SendEmails = false, 
		                          ParentRecordId = newOpportunity.AccountId,
		                          RelatedRecords = 'OpportunityLineItem'); 
		                          
		                    OpportunityConnections.add(newConnection); 
		                
		                } 
		            } 
		  
		            if (OpportunityConnections.size() > 0 ) { 
		                   database.upsert(OpportunityConnections); 
		            } 

 

JFraileJFraile

Hi alaschgari.

 

I see you forward opportunity products, to make auto-acceptance work for these objects the related pricebook and product must be previously shared. Not sure if this matter would afect the opportunity auto-acceptance.

 

Anyways, have you tried manually share the opportunity? Either using the manage connections link or the forward button?

alaschgarialaschgari

Hi JFralle!

 

If I share the opportunity without products manually via forward button without using the trigger, the opportunity is accepted automatically.

If I share the opportunity without products autmatically via trigger, the opportunity is NOT accepted automatically.

In both cases "opportunity auto-acceptance" is turned on in the target org.

JFraileJFraile

I guess the difference between the code execution and the forward button process is the parentrecordId, the forward button may not add any value to this field. So I would try to execute yout code with the  parentrecordId with blank vlaue or with the opportunity Id value.

 

Additionally I would try to share the opportunity via the manage connections link in the related opportunities list in the account detail page. Using this link the parentrecordId will be populated with the account Id.

 

You can also retrieve the PartnerNetworkRecordConnection record you created when sharing the opportunity via the forward button, and check its fields values, so you can compare with the values from your code. 

alaschgarialaschgari

Hi JFraile,

 

you are right! As soon as I remove the line with the ParentRecordId in the trigger code, the opportunity gets accepted automatically in the target org. This is kind of confusing since the original code worked for me in another test org.

 

Sorry, but there's no link called "Manage Connections" in the related opportunity list on the account detail page.

JFraileJFraile

Hi alaschgari,

 

To view this link try adding a field to the opportunity related list on the account page. The field is called Sent Connection Name.
When you have added this field, you will see it has a link called manage connections. Clicking on this link will share the opportunity as a child of the account, so probably auto-acceptance won't work.

 

It seems to be a problem with child auto-acceptance process... When auto-acceptance did work, the opportunity was successfully related to the account? If not, then you should check the opportunity complies all the criteria for child auto-acceptance to work (https://help.salesforce.com/apex/HTViewHelpDoc?id=business_network_auto_accept.htm&language=en_US). If yes, there you go!

This was selected as the best answer
alaschgarialaschgari

In order for a child record to be accepted automatically, the following criteria must be met:

  • The parent record must already be accepted in the organization.
  • The record must be related as a child to the parent record.
  • The child record cannot have two master records.
  • The child record cannot have multiple relationships to the same parent object.

 

I found the reason why auto-acceptance does not work: my opportunity object has 2 lookup-relationships to the account object!

 

THANK YOU VERY MUCH JFraile!!!