Skip to main content
Solved

Change Programatically Customer Class ID answering Yes to warning dialog

  • 8 November 2022
  • 4 replies
  • 403 views

anahizentella94
Jr Varsity III
Forum|alt.badge.img

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.

 

 

Best answer by Fernando Amadoz

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

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+5
  • Captain II
  • 485 replies
  • November 8, 2022

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?


Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+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)


andriikravetskyi35
Jr Varsity I
Forum|alt.badge.img+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();

}


anahizentella94
Jr Varsity III
Forum|alt.badge.img

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings