Skip to main content
Answer

Trying to use Substring is the first part of a SelectFrom Where clause

  • November 18, 2024
  • 2 replies
  • 54 views

Joe Schmucker
Captain II
Forum|alt.badge.img+3

Sorry for posting so many questions lately.  

in my command, I want to get the first two characters of the screen ID. If it is SM, I want to exclude the record from the selection.

 cmd = new SelectFrom<UploadFileRevision>

       .InnerJoin<UploadFile>.On<UploadFile.fileID.IsEqual<UploadFileRevision.fileID>>

       .InnerJoin<ICSUploadFileView>.On<ICSUploadFileView.fileID.IsEqual<UploadFile.fileID>>

       .LeftJoin<ICSSystemFiles>.On<ICSSystemFiles.systemFileName.IsEqual<UploadFile.name>>

     .Where<UploadFile.primaryScreenID.IsNotNull.And<ICSSystemFiles.systemFileName.IsNull>

     .And<Substring<UploadFile.primaryScreenID, int0, int2>.IsNotEqual<SMScreenConstant>>>

     .View(this);

I know Substring can be used in the predicate, but do you know of a way to do it in the subject of the Where?

 

I am using a SQL View since you can do a field not in ("SM") in the where in SQL. I want to get rid of the need for a SQL View if possible.

Best answer by Django

That looks to be exactly how ARInvoiceEntry.cs uses Substring within a PXDefault formula (aside from them using BQL vs FBQL).

What does your SQL trace return for the SQL statement generated by your query?

2 replies

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • November 18, 2024

That looks to be exactly how ARInvoiceEntry.cs uses Substring within a PXDefault formula (aside from them using BQL vs FBQL).

What does your SQL trace return for the SQL statement generated by your query?


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • November 18, 2024

I just figured it out.  I was missing PX.Data.BQL in front of the Substring and It causes an ambiguous reference.
 

As usual, spin for an hour, post a cry for help, figure it out minutes later...

Sorry.  I should have looked at the squiggles.