SalesforceCommerceCloud / b2c-crm-sync

... a contemporary perspective on how to integrate B2C Commerce and the Salesforce Customer 360 Platform to power frictionless customer experiences in the B2C domain.
https://salesforcecommercecloud.github.io/b2c-crm-sync/
BSD 3-Clause "New" or "Revised" License
65 stars 45 forks source link

Get Contact Record : Failed to find records. #126

Open ranveer5289 opened 2 years ago

ranveer5289 commented 2 years ago

Hello,

I am seeing the error when I try to register a new customer on the storefront. In case of registration, the person account is created in SF core but still flow B2CCommerce_PlatformEvent_ProcessContactUpdate ends up in error and the subsequent Quick Actions like Quick Action (Publish to B2C Commerce Profile) fails

In both scenarios, the flow is not able to get the record based on the recordId. We are using person accounts and the accounts are created properly in SF core.

Below is the error log in case of Registration

Error element recGet_Contact (FlowRecordLookup).
This error occurred when the flow tried to look up records: An unexpected error occurred. Please include this ErrorId if you contact support: 1179121620-136887 (-1575307809). You can look up ExceptionCode values in the SOAP API Developer Guide.

Flow Details
Flow API Name: B2CCommerce_PlatformEvent_ProcessContactUpdate
Type: Autolaunched Flow
Version: 1
Status: Active
Org: Some Org

Flow Interview Details
Interview Label: B2C Commerce: Platform Event: Process Contact: 18-02-2022 11:28
Interview GUID: 922861f6f65cdcb192c17f0142dc17f0c420f30-3541
Current User: Current User Name/ID (0057Q000001sVSJ)
Start time: 18-02-2022 11:28
Duration: 0 seconds

How the Interview Started
Current User Name/ID (0057Q000001sVSJ) started the flow interview.
API Version for Running the Flow: 52
Some of this flow's variables were set when the interview started.
$Record = B2C_Commerce_ProcessCustomerDetails__e (No ID)

DECISION: Is ProcessMode Valid
Skipped this outcome because its conditions weren't met: decOutcome_ProcessModeIsInValid
Outcome conditions: 
1. {!$Record.Process_Mode__c} (retrieve) Does not equal retrieve
2. {!$Record.Process_Mode__c} (retrieve) Does not equal publish
Logic: All conditions must be true (AND)

Default outcome executed.

**GET RECORDS: Get the Contact Record**
Find all Contact records where:
Id Equals {!$Record.CRM_Contact_ID__c} (0037Z00001MBRx2QAH)
Store the values of these currently referenced fields in recGet_Contact: AccountId, Id
Because recGet_Contact is passed to an action, subflow, or Lightning component, store the values of all Contact fields that the running user has access to.
Result
**Failed to find records**

Below is the error log in case of Quick Action

Error element recGet_Contact (FlowRecordLookup).
This error occurred when the flow tried to look up records: An unexpected error occurred. Please include this ErrorId if you contact support: 2076699330-232817 (264095063). You can look up ExceptionCode values in the [SOAP API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#).

Flow Details
Flow API Name: B2CCommerce_QuickAction_Contact_ContactRetrieve
Type: Screen Flow
Version: 1
Status: Active
Org: Some Org ID

Flow Interview Details
Interview Label: B2C Commerce: Quick Action: Trigger Customer Details Update 18-02-2022 11:31
Interview GUID: 88981a771d18e92ddf1f606c235a17f0c532e19-19a1
Current User: Current User Name/ID (0057Q000001sVSJ)
Start time: 18-02-2022 11:31
Duration: 0 seconds

How the Interview Started
Current User Name/ID (0057Q000001sVSJ) started the flow interview.
API Version for Running the Flow: 52
Some of this flow's variables were set when the interview started.
recordId = 0017Z00001brrizQAA

SUBFLOW: Retrieve Contact Details
Enter flow B2CCommerce_QuickAction_Contact_GetterHelper version 1.
API Version for Running the Flow: 52
Inputs:
var_recordId = {!recordId} (0017Z00001brrizQAA)

**GET RECORDS: Get Contact Record**
Find all Contact records where:
Id Equals {!var_recordId} (0017Z00001brrizQAA)
Store the values of these currently referenced fields in recGet_Contact: Id
Because recGet_Contact is passed to an action, subflow, or Lightning component, store the values of all Contact fields that the running user has access to.
Result
**Failed to find records.**

Error Occurred: This error occurred when the flow tried to look up records: An unexpected error occurred. Please include this ErrorId if you contact support: 2076699330-232817 (264095063). You can look up ExceptionCode values in the [SOAP API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#).

Transaction Rolled Back
Because an error occurred, any records that the flow was ready to create, update, or delete weren’t committed to the database.

Salesforce Error ID: 2076699330-232818 (-1855315442)

This is a fresh installation on the SFDC sandbox and this sandbox is connected to SFCC sandbox.

I am very new to SF core so maybe I am missing something very obvious? One thing I already note is that when quick action has been invoked the ID shown in the flow debug logs 0017Z00001brrizQAA is the ID of the Account and not the Contact 0037Z00001MBRx2QAH but I assume this is the standard setup of the connector as I didn't change anything.

ranveer5289 commented 2 years ago

Ok, I figured it out.

It seems one of the fields on the contact record doesn't have proper field-level security set for the SF profiles like system admin. When we use the GetRecord element with the setting Automatically store all fields it seems this internally loads/queries all the fields on that found Contact Record and since one of the field doesn't have proper security set the element GetRecord was throwing an exception.

Still the exception was quite vague. Is there any reason why we use the Automatically store all fields setting? Sounds a bit inefficient to query all fields when our only purpose is to check if contact with that ID exists or not.

jbachelet commented 2 years ago

Hello @ranveer5289, Thank you for opening this issue.

The b2c-crm-sync framework is using permission sets to grant users the access they need. Is your user part of this permission set? This might be the root cause of your issue.

Anyway, you are raising a really good point on the Automatically store all fields setting. I'll review this and might provide a pull request to lower the scope of fields retrieved to only the record ID when required.

Thanks