Why does this customized selector attribute not allow selection?
I have this customized selector attribute to filter Projects to the current customer on CRActivityMaint:
public class DSRestrictActivityProjects_CRActivityMaint_Ext : PXGraphExtension<CRActivityMaint> { [PXRemoveBaseAttribute(typeof(EPProjectAttribute))] [CustomerProjects] protected virtual void _(Events.CacheAttached<PMTimeActivity.projectID> e) { }
public class CustomerProjects : PXCustomSelectorAttribute { public CustomerProjects() : base(typeof(PMProject.contractID), typeof(PMProject.contractCD), typeof(PMProject.description), typeof(PMProject.status)) { SubstituteKey = typeof(PMProject.contractCD); DescriptionField = typeof(PMProject.description); }
public virtual IEnumerable GetRecords() { CRActivity activity = (CRActivity)_Graph.Views["CurrentActivity"].Cache.Current; if (activity is null || activity?.RefNoteID is null) return null;
You obviously spent some time on this. Thank you. I'll give it a shot.
I have two issues with your solution:
I’m a little bit hesitant to change the field type. It seems like there would be a reason they used the field type they did, or issues if it were changed?
I tried removing the ‘where’, and while it does show projects, it does not show only projects for the current Customer if the current Activity is tied to a Case, which was the original goal
So using your observations, I instead tried implementing a customized PXDimensionSelector like this:
public class CustomerProjects2 : PXCustomDimensionSelectorAttribute { public CustomerProjects2() : base("PROJECT", typeof(PMProject.contractID), typeof(PMProject.contractCD), typeof(PMProject.contractCD), typeof(PMProject.description), typeof(PMProject.status)) { }
public override IEnumerable GetRecords() { CRActivity activity = (CRActivity)*noGraph*.Views."CurrentActivity"].Cache.Current; if (activity is null || activity?.RefNoteID is null) return null;
The problem is, there is no ‘_Graph’ attribute that I can find to allow getting the current Activity, which means the results are not filtered.
I also can’t find any documentation for this situation.
@darylbowman I don’t think those are the issues, which I have provided and that is one of the solutions to resolve your issues.
As you mentioned about “DimensionSelector”, you can also use my solution with the DimensionSelector, so that we can use the SegmentMask instead of Selector.
but yes, PXCustomDimensionSelectorAttribute we will not have the _Graph, and I never tried with this.
I recommend you to raise a support case with Acumatica.
Hi.
I’m incredibly late to the party, but my team found this topic when they were trying to resolve a similar issue.
In case someone else stumbles upon this, we’ve seen the issue that using the private PXGraph field with setting it in the CacheAttached didn’t help them because the value of the field was resetting somewhere along the way.
Here’s the solution that worked:
public class SampleDimensionSelectorAttribute : PXDimensionSelectorAttribute { private const string _dimension = "SAMPLE"; private const Type _type = typeof(SampleDac.SampleDacID); private const Type _substituteKey = typeof(SampleDac.SampleDacCD); private const Typec] _fieldList = new Type=] { typeof(SampleDac.SampleDacCD), typeof(SampleDac.descr) };