Skip to main content
Question

Accessing protected fields

  • May 24, 2023
  • 3 replies
  • 226 views

Forum|alt.badge.img+1

Hello,
I’ve created code to overwrite a protected method called Bill in the contract billing class, by extending the CTBillEngine graph.
This is quite an involved method which calls out to other protected methods within the same CTBillEngine class. I’ve used [PXProtectedAccess] to create abstract methods, so I can call the protected methods and this is working great.

One of the protected methods references a field which is defined in the following way:

protected Dictionary<int?, decimal?> availableQty = new Dictionary<int?, decimal?>();

I know how to access protected properties and methods in a base class using the PXProtectedAccess attribute, but how can I access a protected field from an extended class? 

In standard c# this is simple, the inherited class has automatic access to a protected field, but this isn’t the case with the Acumatica framework. I’ve tried using PXProtectedAccess on a field but it displays a message saying PXProtectedAccess is only valid on ‘class, method, property and indexer declarations’.

I’m stuck now, does anyone know how to do this please?


Thanks
Steve

3 replies

darylbowman
Captain II
Forum|alt.badge.img+15

I’m assuming you’ve seen this, but I hadn’t, so thanks for that.


Forum|alt.badge.img+1
  • Author
  • Varsity III
  • May 24, 2023

Yes I have. It’s a very good article and covers methods and properties. But not normal fields. 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • June 21, 2023

Hi @stephenward03 were you able to find a solution? Thank you!