Solved

Change Programatically Customer Class ID answering Yes to warning dialog

  • 8 November 2022
  • 4 replies
  • 286 views

Userlevel 4
Badge

I’m creating a new Customer but I want to change the Customer Class ID different from the default Customer Class ID.

When the new value is assigned, I got a Web Dialog Warning. I want to answer Yes to that dialog programmatically, how can I do it?

I’m getting an Exception because I can’t answer Yes to the dialog.

 

 

icon

Best answer by Fernando Amadoz 8 November 2022, 19:36

View original

4 replies

Userlevel 7
Badge +5

This post on SO shows how you can set the value that you want the dialog to use:

https://stackoverflow.com/questions/56360479/how-to-pass-value-to-confirmation-popup-from-custom-screen/56365751#56365751

However, I feel like you should be able to set up the new Customer record with the different customer class ID without invoking the business logic by setting the desired value of the Customer Class ID.

Can you share your code?

Userlevel 5
Badge +2

@anahizentella94 in those cases, your logic should include the response right before the field that triggers the smartpanel is assigned.
Here is an example from the Service Order page:

//Answer is given in advance:
serviceOrderGraph.ServiceOrderRecords.View.Answer = WebDialogResult.Yes;
//Logic that prompts the smartpanel is added:
serviceOrderGraph.uncloseOrder.Press();

in your case, rather than pressing on UncloseOrder, you would be assigning the new CustomerClass value (make sure to either use SetValueExt<> or Update the cache right after the value is assigned)

Userlevel 5
Badge +1

Hi everybody,

I used this approach with try...catch:

{

CustomerMaint graph = PXGraph.CreateInstance<CustomerMaint>();

Customer exiCust =    Customer.PK.Find(graph, bAccountID);

string newCustomerClassID = “NeededClassIDValue”;

cust.CustomerClassID = newCustomerClassID;

 try
     {
        graph.CurrentCustomer.Update(exiCust);
      }
  catch
      {
         graph.BAccount.View.Answer = WebDialogResult.Yes;
      }

graph.Persist();

}

Userlevel 4
Badge

Thanks for your answer, it worked with the @Fernando Amadoz’s suggestion

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