When we want to check button or any field’s UI attribute that is Enabled or not. how can we perform it?
Solved
How can we check button or field enabled or other attributed in code?
Best answer by yhartman
I did some research in the source code and it seems you can get a fields attribute in the following way.
cache.GetAttributesOfType<PXUIFieldAttribute>(null, nameof(field)).FirstOrDefault().Enabled;
I also found an extension that does this for you. However, aside for the extension being there, I have not seen it used anywhere in the source code.
using PX.Objects.CN.Common.Extensions;
bool foo = CacheExtensions.GetEnabled<field>(e.Cache, null);
I hope this helps!
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.