Hi @ShahidaValiSyed04 Do you have any specific reason to create a view with extension DAC? System will not support to create view with extension DAC Normally We can get the value or assign the value using the GetExtension Example: SOOrderExtn orderExtn = Base.Document.Current.GetExtension<SOOrderExtn>(); orderExtn?.UsrField1= “Test”; string val = orderExtn?.UsrField1; Is it possible to get a list that contains the extension data (with our without the base data) or do we have to loop over the list of base data and call GetExtension every time?
if(PXInstanceHelper != null && PXInstanceHelper.CurrentCompany != null){ //...log stuff here} I think this is pretty lightweight and should work….absent more context on what you’re trying to achieve. Why not check if the property is null? Thanks, @rosenjon, that is a good suggestion.I would really like an event to listen to on any PXInstanceHelper.CurrentCompany changes (or an event downstream from there), but that does not seem to be available.
My logging will certainly not break the site, that was a comment about the sample code provided.I do not do queries in my logging routine, I only extract the company id to include in the logging data. I don’t query the logs at any time during the logging procedure.My logging is limited to only my routines and will have no impact on the rest of the site.Data that is included in the logs is controlled by verbosity and level settings, so I make sure I do not log any data that is not wanted.
Thanks for the suggestion rosenjon.Technically that would take a lot more processing power than to check a bit flag for a given state. I am doing that currently, but would prefer a more elegant solution.I would love to hear the other things that you can think of 😀
It’s hard to give a code sample that will reproduce my scenario. It is in my exception logging procedure that can be called from many places in our code. The below code will produce the same exception, but it’s not quite what my code does.This code will clearly break an environment as it will error out on all graphs before the user logs in, but it illustrates the issue. public class PXBaseGraph_Extension : PXGraphExtension<PXGraph> { public static bool IsActive() { return true; } public override void Initialize() { //TODO: check if logged in before calling this var id = PXInstanceHelper.CurrentCompany; } }
That is correct, yes, and I’m looking for a way to detect if I am in a company or not before I make the call and get the exception
Thanks for all the help.I am getting the error when I attempt to read the PXInstanceHelper.CurrentCompany property.A search of that property in the open-source code has not helped me to avoid the exception, and I’d prefer to not just wrap it in an exception handler, if avoidable.
Is there no status in a .Net object I can test from within a graph?I looked at the below objects but cannot see anything:PXAccessCommonServiceLocator.ServiceLocator.Current.GetInstance<ICurrentUserInformationProvider>()PXInstanceHelper
Hi @SLavigueur ,Apologies for the delayed response. I have exception logging routines that includes the user’s current company detail. I use the code instead of CompanyID to accommodate for queries across all logs. It may happen that my logger catches an exception before a user has logged in, or after they have logged out, in which case I would like to log a blank code
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.