Solved

How do I go about overriding the field verifying event for Customer Class ID?

  • 12 July 2022
  • 3 replies
  • 254 views

Userlevel 5
Badge +1

I wanted to set the default button in the Messagebox to be NO but apparently can’t do that.  As a workaround I need to override the following:

protected virtual void Customer_CustomerClassID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
{
Customer row = (Customer)e.Row;
CustomerClass cc = (CustomerClass)PXSelectorAttribute.Select<Customer.customerClassID>(cache, row, e.NewValue);
this.doCopyClassSettings = false;
if (cc != null)
{
this.doCopyClassSettings = true;
if (cache.GetStatus(row) != PXEntryStatus.Inserted)
{
if (BAccount.Ask(Messages.Warning, Messages.CustomerClassChangeWarning, MessageButtons.YesNo) == WebDialogResult.No)
{
this.doCopyClassSettings = false;
}
}
}
}

I have changed the warning message by adding a translation for the warning message as by default we want YES to only change the class ID and nothing else. How do I go about overriding the code to match?  I only want to change the if statement to action on WebDialogResult.Yes instead of .No.

I tried just selecting to override the field event handler for fieldverifying, copying and pasting the code in from the source and changing just that line but I get a bunch of errors so I don’t think I’m doing it correctly.

Any advice or pointers to tutorials related to overriding existing event handlers would be very much appreciated.

The errors I get are as follows in case it helps:

\App_RuntimeCode\CustomerMaint.cs(47): error CS1061: 'CustomerMaint_Extension' does not contain a definition for 'doCopyClassSettings' and no accessible extension method 'doCopyClassSettings' accepting a first argument of type 'CustomerMaint_Extension' could be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\CustomerMaint.cs(50): error CS1061: 'CustomerMaint_Extension' does not contain a definition for 'doCopyClassSettings' and no accessible extension method 'doCopyClassSettings' accepting a first argument of type 'CustomerMaint_Extension' could be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\CustomerMaint.cs(53): error CS0117: 'BAccount' does not contain a definition for 'Ask'
\App_RuntimeCode\CustomerMaint.cs(55): error CS1061: 'CustomerMaint_Extension' does not contain a definition for 'doCopyClassSettings' and no accessible extension method 'doCopyClassSettings' accepting a first argument of type 'CustomerMaint_Extension' could be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\CustomerMaint.cs(47): error CS1061: 'CustomerMaint_Extension' does not contain a definition for 'doCopyClassSettings' and no accessible extension method 'doCopyClassSettings' accepting a first argument of type 'CustomerMaint_Extension' could be found (are you missing a using directive or an assembly reference?)

Thanks,

 

Phil

 

icon

Best answer by Dioris Aguilar 12 July 2022, 18:48

View original

3 replies

Userlevel 5
Badge +2

 @ppowell The doCopyClassSettings field is defined as private in CustomerMaint, therefore, it cannot be accessed by the extension.
My suggestion is to create your own UsrdoCopyClassSettings field in the extension and check all the places where it is used to override those methods and use your UsrdoCopyClassSettings field.


Warning: This approach is a little risky when upgrading the customization since if the base code changes and the original doCopyClassSettings field is used in a different way or is removed, then your code will be left out-dated.

Deleted - wrong comment.

Userlevel 5
Badge +1

@Dioris Aguilar Thanks for taking the time to reply.  I understand the problem now and possible workaround.  I take your point that it’s risky and will mean extra work to check in future upgrades.  We’ll have to decide if it’s worth the risk I guess.

 

Thanks once again,

 

Phil

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