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
64 stars 47 forks source link

[BUG] Flow error on LastName update: "You have uncommitted work pending. Please commit or rollback before calling out" #115

Closed josecervera-salesforce closed 1 year ago

josecervera-salesforce commented 2 years ago

Describe the bug A flow error occurs when updating the contact's LastName: "You have uncommitted work pending. Please commit or rollback before calling out". First, B2C starts the flow that updates the contact ("B2C Commerce: Process: Create Or Update Contact"). This first flow updates the contact, account name, and this fires two triggers ("B2C Commerce: Trigger: Contact: Set Account Name" and "B2C Commerce: Trigger: Contact: Set Site OOBO Properties" ), and then launches an event, that is handled in the flow labeled "B2C Commerce: Platform Event: Process Contact Update". The error appears in this second flow, in the B2CIAGetCustomerProfile.getCustomerProfile method.

To Reproduce Log in as a customer in the B2C front end; in the account section change the personal details to update the last name. Default settings are used (contact sync enabled, etc). Tested on both modes (PersonAccount, and Contact + Account) with the same result.

Expected behavior No errors in the flow appear. However, even though the contact details and the account name are correctly changed, the flow finishes in error, as the callout to get the customer's profile fails.

Your local environment details: Tested with b2c-crm-sync versions 0.9.0 and 1.1.0

nek4life commented 2 years ago

I just ran into the same issue. I'm creating records from an email signup form without a last name and putting in a dummy last name since last names are required when creating a Person Account (maybe regular contacts too, not sure.)

I then registered a user account with the same email to see if the connector would find the same newly created person account. The connector was able to find and update the correct user. I did see the record update in Service, but received the same flow error.

syunyama commented 2 years ago

I had same error. It seems updating Contact from "B2C Commerce: Process: Create Or Update Contact" flow trigger "B2CProcessContact". Is it necessarily? I thought the trigger should be invoked only when updating from UI.

If it is correct, putting additional attribute like is_from_flow and assigning true in the flow and skipping trigger by it could work.

nek4life commented 2 years ago

We're having trouble with a workflow rule and wondering if this error would cause a workflow rule to fail. Any ideas how to fix this issue?

ranveer5289 commented 2 years ago

We are also facing the same error. In our case, the error appears when we try to update the profile of the customer from my account.

Error element ia_retrieveB2CCommerceCustomerProfile (FlowActionCall). An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

B2CIAGETCUSTOMERPROFILE (APEX): Retrieve the B2C Commerce Customer Profile Error Occurred: An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

aKentorp commented 2 years ago

We are facing this issue aswell when updating a customer. Getting: Error element ia_retrieveB2CCommerceCustomerProfile (FlowActionCall). An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out As far as we can tell, the contact is updated correctly, and right now we are trying to figure out if this callout is necessary for the job to work.

ranveer5289 commented 2 years ago

@jbachelet : Is there any update on this issue? We are also facing this issue on our live SF org.

mkulshershtha commented 2 years ago

hi everyone, We are facing this one when we went live last week, any one please share some pointer to resolve this,

Inputs

apiUrl = {!recGet_B2CCustomerList.Base_API_Urlc} (https://prd.drops.online) apiVersion = {!$Record.OCAPI_Version_Numberc} (v21_03) b2cAuthToken = {!B2CAuthToken} () b2cCustomerListId = {!$Record.B2C_CustomerList_IDc} (Drops) b2cCustomerNo = {!$Record.B2C_Customer_Noc} (00288014) crmContactId = {!$Record.CRM_Contact_IDc} (0038a000035EpxhAAC) crmCustomerListId = {!$Record.CRM_CustomerList_IDc} (a5E8a000000FahkEAC) Info Error Occurred:

An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

jbachelet commented 1 year ago

Hello,

This has been fixed in #212 and released in v2.0.0.

Thanks