2
votes

I have tried multiple ways, but getting Another process error in the default version of Acumatica 19.106.0020

On top of it i have a customized code on both customer and contact screen, my requirement to clear the value of the custom field that is created in contact table when customer is deleting from the screen AR303000 i need to set null value of the custom field for the deleted contact from the customer.

i have tried by setting value on Customer_RowDeleting event but continuously getting Another process error, below is the screenshot error

enter image description here

Below is the code that i was tried

 protected virtual void Customer_RowDeleting(PXCache sender, PXRowDeletingEventArgs e, PXRowDeleting BaseEvent)
        {
            BaseEvent?.Invoke(sender, e);
            Customer rows = e.Row as Customer;
            if (rows == null)
                return;
            if (Base.BAccount.Cache.GetStatus(Base.BAccount.Current) == PXEntryStatus.Deleted)
            {
                foreach (Contact BACT in PXSelectReadonly<Contact,
                                   Where<Contact.bAccountID, Equal<Required<Contact.bAccountID>>,
                                   And<Contact.contactType, NotEqual<ContactTypesAttribute.bAccountProperty>>>>.Select(Base, rows.BAccountID))
                {
                    ContactMaint congraph = PXGraph.CreateInstance<ContactMaint>();
                    Contact CTData = PXSelectReadonly<Contact,
                        Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, BACT.ContactID);
                    if (CTData != null)
                    {
                        congraph.Contact.Current = CTData;
                        if (congraph.Contact.Current != null)
                        {
                            congraph.Contact.SetValueExt<ContactExt.usrKWBAccountId>(congraph.Contact.Current, null);
                            congraph.Contact.Update(congraph.Contact.Current);
                            congraph.Save.Press();
                        }
                    }
                }
            }
        }

Thanks in advance.

Hi Chris, please find the attached image here

enter image description here

1

1 Answers

0
votes

I don't recommend to create graphs during RowDeleting event. If you have Acuminator installed, you will see a warning about creating graphs in event handlers. Instead, call your custom code during the Persist method. Persist method is called during Delete operation. After the Base persist is finished, your custom code can perform it's work. Try something like this

public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{        
    public delegate void PersistDelegate();
    [PXOverride]
    public void Persist(PersistDelegate baseMethod)
    {   
        Customer currentCustomer = Base.CurrentCustomer.Current;  //get the customer record before it's deleted, i.e. Customer.bAccountID
        baseMethod();  //let the base delete process happen first
        if (Base.CurrentCustomer.Cache.GetStatus(currentCustomer) == PXEntryStatus.Deleted)
        {
            using (PXTransactionScope ts = new PXTransactionScope())
            {
                //here is where you add your code to delete other records

                ts.Complete();    //be sure to complete the transaction scope
            }
        }
    }
}

Also you might want to unpublish other customization packages, and see if the error continues without those packages. That is one way to determine the source of the error...by process of elimination.