Skip to main content

Hi, I’m working on a custom validation that requires looking up PO commitments  for a given Branch/ExpenseAcct/ExpenseSub/Fiscal Year. The fiscal year is a custom field that was added as an extension to the POLine DAC. I’ll be converting this query to fetch the sum of unbilled amounts, but for now I’m just trying to get the correct lines to be filtered and I’m getting a crash (stack overflow on FIeldVerifying) when my current BQL query is executed. Is there something I’m missing to be able to connect the POLineExt in this query?

public SelectFrom<POLine>
.Where<POLine.branchID.IsEqual<@P.AsInt>
.And<POLineExt.usrFiscYr.Contains<@P.AsString>>
.And<POLine.expenseAcctID.IsEqual<@P.AsInt>>
.And<POLine.expenseSubID.IsEqual<@P.AsInt>>
>.View POLineView;

Thank you!

If you peek into the database you’ll see that your Usr fields have been tacked on to the POLine table (unless you did something specifically to keep your fields in a separate table).

So for queries like yours, you can just reference the field:

Edit - I didn’t notice you have the line already in the query.

What are you sending for the parameter value for that field? “Contains” can be a little odd to play with.

public SelectFrom<POLine>
.Where<POLine.branchID.IsEqual<@P.AsInt>
.And<POLineExt.usrFiscYr.Contains<@P.AsString>>
.And<POLine.expenseAcctID.IsEqual<@P.AsInt>>
.And<POLine.expenseSubID.IsEqual<@P.AsInt>>
>.View POLineView;

 


What are you sending for the parameter value for that field? “Contains” can be a little odd to play with.

I’m sending the fiscal year as a 4 character string for the parameter (ie: “2025”). The actual value stored in the extension field is a fiscal period designator, so the data in it is something along the lines of “06-2025”. I’m trying to get all amounts in 2025 and not just for a specific period.


It sounds like you want .IsLike<@P.asString> and put the ‘%’ character on the left side of your parameter value.


Looks like my issue was mainly being caused by attempting a .Any() check on the POLineView object. 

After I changed the line from a .Contains to a .BeginsWith and added the AggregateTo clause to get the sum of unbilled transactions (removing the need to use the .Any ) the Stack Overflow error has stopped. Thanks for your help.

Now my issue has changed to not being able to display a warning validation error on the ExtCost field, which is strange because this appeared to be working in a test I did on the subaccount field. Is there something special about the ExtCost field that would be preventing this message from appearing there?

e.Cache.RaiseExceptionHandling<POLine.extCost>(
e.Row, e.NewValue, new PXSetPropertyException(e.Row,
message, PXErrorLevel.Warning));

 


What event is your RaiseExceptionHandling code within?


What event is your RaiseExceptionHandling code within?

protected virtual void _(Events.FieldVerifying<POLine, POLine.curyExtCost> e)


wait… as I sent that I just noticed its the curyExtCost and not the ExtCost. Might’ve just found my issue. Thanks!


Still having an issue here. I’ve tried changing both the FieldVerifying event and the RaiseExceptionHandling to POLine.curyLineAmt since that is the field visible on screen, but I still can’t get the warning to display. I’ve also tried to change to PXErrorLevel.RowWarning, but that doesn’t do anything either. I’ve traced in debug to be sure this line of code is being reached and executing. I’m at a bit of a loss as to why I can’t get anything to display.


I wasn’t able to figure out why the warning isn’t displaying with the FieldVerifying event, but digging around the web for answers I came upon a suggestion to use 

protected virtual void _(Events.RowSelected<POLine> e)

instead, and that seems to be working as I intend it.

Thanks for all your help!


Thank you for sharing your solution with the community @kevlynch!


Reply