Skip to main content
Answer

Stop a page from loading with public static bool IsActive()

  • June 27, 2025
  • 8 replies
  • 98 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

I want to prevent a custom page from loading based on a condition.  For example, I want to put an expiration date on my custom application.  When the application date has expired, I want to prevent the page from being accessed.  I’m trying to roll my own security on my custom app.

I found documentation that used this scenario:

public static bool IsActive() => PXAccess.FeatureInstalled<FeaturesSet.someFeature>();

If I put public static bool IsActive() => false; in my graph, should that prevent the page from loading?  It doesn’t seem to have any effect.

If that is not the way to do it, does anyone know how?  

 

Best answer by Josiah Lisle

I tried restarting IIS, resetting the caches, restarting the application (multiple times) but no joy.

After doing some more reading, I am wondering if this only applies to deactivating extensions of graphs, not primary graphs.

Hi Joe,

It looks like you are correct, IsActive() only applies to extensions. I did find this post which seems to indicate you can throw an exception in the constructor to do what you are looking for:

https://stackoverflow.com/questions/62648623/turn-on-off-a-custom-page-feature-based-on-tenant-in-acumatica

I haven’t tested this but let me know if it works!

8 replies

Forum|alt.badge.img
  • Freshman II
  • June 27, 2025

I want to prevent a custom page from loading based on a condition.  For example, I want to put an expiration date on my custom application.  When the application date has expired, I want to prevent the page from being accessed.  I’m trying to roll my own security on my custom app.

I found documentation that used this scenario:

public static bool IsActive() => PXAccess.FeatureInstalled<FeaturesSet.someFeature>();

If I put public static bool IsActive() => false; in my graph, should that prevent the page from loading?  It doesn’t seem to have any effect.

If that is not the way to do it, does anyone know how?  

 

Hi Joe,

Yes, the logic you added should work. However, keep in mind that in local environments, changes like this sometimes take a bit to reflect due to caching.

If you're not seeing the effect right away, try restarting IIS. In many cases, restarting IIS and then refreshing the screen in your browser helps force the changes to take effect.

After that, the page should behave according to your IsActive() implementation.

Hope that helps!


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • June 28, 2025

I tried restarting IIS, resetting the caches, restarting the application (multiple times) but no joy.

After doing some more reading, I am wondering if this only applies to deactivating extensions of graphs, not primary graphs.


Forum|alt.badge.img+1
  • Jr Varsity I
  • Answer
  • July 2, 2025

I tried restarting IIS, resetting the caches, restarting the application (multiple times) but no joy.

After doing some more reading, I am wondering if this only applies to deactivating extensions of graphs, not primary graphs.

Hi Joe,

It looks like you are correct, IsActive() only applies to extensions. I did find this post which seems to indicate you can throw an exception in the constructor to do what you are looking for:

https://stackoverflow.com/questions/62648623/turn-on-off-a-custom-page-feature-based-on-tenant-in-acumatica

I haven’t tested this but let me know if it works!


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • July 2, 2025

IsActive only works for extensions (graph extensions or cache extensions).

For disabling the graphs the recommended way would be to throw a PXSetupNotEnteredException from Initialize method or a graph constructor.


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • July 3, 2025

@Dmitrii Naumov Hi Dmitri.  For a production instance of Acumatica, where there is a license being used, is there a call to some Acumatica service/API every time a page is loaded to validate the instance is authorized and return license information?

Or is the license key managed by a DLL within the Acumatica product?

I’m thinking of creating an API that can be called when my page is opened that will return data such as allowed URL and expiration date.  If I put any kind of decryption of a key in my library, it will be relatively easy for someone to reverse engineer my key.  If I did use a private API, that would mean the user must be connected to the internet.  For an Acumatica test instance (my dev environment), there is no data in the Licensing table, so perhaps that is why I am defaulted to 2 users and I can do development while not connected to the web.  

 If you do not wish to divulge this information, NO PROBLEM.  


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • July 3, 2025

Hi ​@Joe Schmucker 

Acumatica requests license information once a week and stores it locally. It does not do it on the each page open. 

Doing it on each page load seems like an overkill to me, but depends on how much you want to protect your product from unauthorized usage. There is no 100% way to guarantee only licensed usage, so it’s always a tradeoff between more robustness of the mechanism and the issues it introduces.

 


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • July 3, 2025

Hi ​@Joe Schmucker 

Acumatica requests license information once a week and stores it locally. It does not do it on the each page open. 

Doing it on each page load seems like an overkill to me, but depends on how much you want to protect your product from unauthorized usage. There is no 100% way to guarantee only licensed usage, so it’s always a tradeoff between more robustness of the mechanism and the issues it introduces.

 

Does that mean that someone could update the license table (for one week only)?  I’m not intending to do that of course!  

Thank you for the quick reply!  I’ve been sitting and staring at my PC for 2 days.  HA!


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • July 3, 2025

@Joe Schmucker theoretically that could happen, yes. I’m not sure it’s a table specifically, more likely it’s stored in memory, but I’m not 100% sure where exactly.