Skip to main content
Answer

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

  • March 6, 2024
  • 4 replies
  • 238 views

Forum|alt.badge.img+1

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.

 

Best answer by Vignesh Ponnusamy

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,

4 replies

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+4
  • Acumatica Moderator
  • March 6, 2024

@saikrishnav35 

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

Acumatica Override Opportunity Create SO action


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • March 6, 2024

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();

 


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

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,


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • March 7, 2024

Hello @Vignesh Ponnusamy 

The above solution works as expected. Thank you!