0

I create a custom DAC, which contains a BranchID field. The client's requirements for this field, is to insert the value 0, as default. The field is defined as a KeyField, but no PXDefault attribute is defined. I use PXRowPersisting event handler, in order to set the value in cases of 0. I use a ListView screen, in order to return the records. But no records are returned. I noticed in the SQL trace, that a filter is applied to BranchID field:

AND ([MyCustomTable].BranchID IS NULL OR [MyCustomTable].BranchID IN (16, 17, 20))

Why is this filter added?

RuslanDev
  • 6,718
  • 1
  • 14
  • 27
Chris H
  • 705
  • 5
  • 11
  • But did you use the Branch attribute in your BranchID field ? – Rick Feb 22 '18 at 02:24
  • I removed the selector entirely. The but where clause is still added [PXDBInt(IsKey =true)] [PXUIField(DisplayName = "Building ID")] public virtual int? BranchID { get; set; } public abstract class branchID : PX.Data.IBqlField { } – Chris H Feb 22 '18 at 04:30
  • That is interesting. Could be something in the framework looking for the standard name of "BranchID". What happens if you change the name of the field to something different (Ex: "MyBranchID"). This would confirm the framework matching by name and might be your best bet to get around the issue you described. Why it occurs I don't know but it would make sense maybe based on user rights to branch access? – Brendan Feb 22 '18 at 14:31

1 Answers1

0

For any table, that contains BranchID or UsrBranchID column, the framework automatically includes the BranchID condition into Where clauses. No matter what attributes are applied on a DAC field, if partucular DAC is bound to the table containing BranchID or UsrBranchID column, the BranchID condition will be added into all Where clauses generated for this table.

For your specific scenario, a possible solution would be to rename BranchID column to something different than BranchID or UsrBranchID. If you will ever need to force application of the Branch-based access restriction to your custom DAC, just add the MatchWithBranch<MyDAC.myBranchID> operator into a BQL query.

RuslanDev
  • 6,718
  • 1
  • 14
  • 27