Skip to main content

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.

 

 

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?


@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)


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

}


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


Reply