Solved

How to override Change ID button and execute through code to update Customer ID.

  • 6 March 2024
  • 4 replies
  • 104 views

Userlevel 1
Badge

HI Team

We have a requirement where we want to override the ChangeID button in customer screen and need to update the CustomerID value through code. We also want to do it at the time of Customer sync from Bigcommerce to Acumatica.

Could someone be able to assist me with this? I would greatly appreciate any help.

 

icon

Best answer by Vignesh Ponnusamy 6 March 2024, 20:37

View original

4 replies

Userlevel 7
Badge +4

@saikrishnav35 

You wanna utilize method delegate for this purpose. Review the following example for guidance:

Acumatica Override Opportunity Create SO action

Userlevel 1
Badge

Hi @RohitRattan88 

 thank you for the response, I reviewed the link but that does not helps with our requirement.

The ChangeID button and related logic we have to execute through code. From screen screen if we click the button it will open a pop up where we have to give new Customer ID value. Now when we try to achieve that through code we it is not working as expected. please find sample code below:

            CustomerMaint customerMaint = PXGraph.CreateInstance<CustomerMaint>();
            customerMaint.BAccount.Current = customer;
            ChangeIDParam changeID = new ChangeIDParam();
            changeID.CD = "11223355";

            customerMaint.ChangeID.PressButton();

 

Userlevel 7
Badge +4

Hey @saikrishnav35,

PXChangeID class in PXData that implements an action ChangeCD which does the job behind the scenes. 

ChangeID in the CustomerMaint is a class instance of the PXChangeID class. I’m not sure if it is possible to customize modify the ChnageID action in CustomerMaint. Instead you can create a new action in the CustomerMaint, then use the static method ChangeCD available in PXChangeID class.

        public PXAction<Customer> changeIDUpdated;
[PXUIField(DisplayName = "Change ID Updated")]
[PXButton(SpecialType = PXSpecialButtonType.ActionsFolder)]
protected IEnumerable ChangeIDUpdated(PXAdapter adapter)
{
string oldCD = "Test37"; // write your existing CD
PXGraph graph = PXGraph.CreateInstance<CustomerMaint>();
PXCache<PX.Objects.AR.Customer> subCache = graph.Caches<PX.Objects.AR.Customer>();
graph.Views.Caches.Add(typeof(PX.Objects.AR.Customer));
subCache.Current = PX.Objects.AR.Customer.UK.Find(graph, oldCD);
PXChangeID<PX.Objects.AR.Customer, PX.Objects.AR.Customer.acctCD>.ChangeCD(subCache, oldCD, "NewID");
subCache.Update(subCache.Current);
graph.Actions.PressSave();
return adapter.Get();
}

In the above example, I’ve created an instance of the CustomerMaint graph and have worked based on it.

You can try something like above during the BigCommerce syn. Hope that helps.! Good Luck,

Userlevel 1
Badge

Hello @Vignesh Ponnusamy 

The above solution works as expected. Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved