Skip to main content

Hi Team,

 

We are working with 24R2 (Build version) and created a custom processing screen to create Sales Order but during processing we are getting an error like: 'Another process has updated the 'SOContact' record. Your changes will be lost'. But the same is working in previous build (Build version)

 

On further verification we identified the issue occurs while updating Sales Order Contact and on executing Save action getting another process error, without this code block order created successfully.

 

Please find the below sample code for your verification and review:

 

public static void SetBillingContact(SOOrderEntry graph, ItemResult OrderDetails)
        {
            graph.Billing_Contact.Current = (SOBillingContact)graph.Billing_Contact.Select();
            if (graph.Billing_Contact.Current != null && OrderDetails != null && OrderDetails.BillingAddress != null)
            {
                graph.Billing_Contact.Current.OverrideContact = true;
                graph.Billing_Contact.Update(graph.Billing_Contact.Current);

 

                graph.Billing_Contact.Current.FullName = OrderDetails.BillingAddress.FirstName + " " + OrderDetails.BillingAddress.MiddleInitial + " " + OrderDetails.BillingAddress.LastName;
                graph.Billing_Contact.Current.Phone1 = OrderDetails.BillingAddress.PhoneNumber;
                graph.Billing_Contact.Current.Email = OrderDetails.BillingAddress.EmailAddress;
                graph.Billing_Contact.Current.Attention = OrderDetails.BillingAddress.CompanyName;
                graph.Billing_Contact.Update(graph.Billing_Contact.Current);
            }
        }

Also attached the full code file for reference.

Thank you in advance !

Hi ​@sruthic25 ,

This code appears to select the default contact for the customer from the SOContact table, modify it to be non-default, and then update it with the data specified on the input form.

The updated SOContact record might already be referenced by existing sales orders. As a result, this update could unintentionally modify contact details for those orders. To prevent such unsafe updates, the Acumatica code includes a condition (IsDefaultContact = false) for this update, which leads to the observed error.

To resolve this issue, the code should explicitly create a new contact (and address record) and assign it to the Billing_Contact (or Address) cache. This ensures that the updates are isolated to the intended record without affecting existing sales orders.

 

                    SOBillingContact contact = new SOBillingContact();

contact.OverrideContact = true;

contact.FullName = KNTfilter.Current.FullName;

contact.Email = KNTfilter.Current.Email;

contact.Phone1 = KNTfilter.Current.PhoneNumber;

contact.CustomerID = graph.Document.Current.CustomerID;

contact.RevisionID = 0;

graph.Billing_Contact.Current = contact = graph.Billing_Contact.Insert(contact);

graph.Document.Current.BillContactID = contact.ContactID;

 


HI ​@jinin  We have tried with the above code and able to Import the order with the Adress and Contact details.
Thanks for the solution, it worked 


Add another thanks from me ​@jinin - I spent far too long trying to figure this out.


Reply