Skip to main content
Answer

New custom program errror: Sequence contains no matching element

  • April 25, 2025
  • 2 replies
  • 137 views

Forum|alt.badge.img

New Form/Grid program error sequence contains no matching element.  In the customization project, I can see the field when I add data fields, but when I save I get the error.  It happens if I add a data field to the form or to the grid.

I have written similar programs to this that work.  Cannot figure out what I have wrong on this one. 

I know the filter on SO works and the Order Types that start with T.  I have tested that statement in SQL.  

Program:

using System;
using MCB_Custom.MspData.DAC;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.IN;
using PX.SM;
using PX.Objects.SO;
namespace MCBCustom
{
    public class TagSchedule : PXGraph<TagSchedule>
    {

        public PXSave<TagScheduleFilter> Save;
        public PXCancel<TagScheduleFilter> Cancel;
        public PXFilter<TagScheduleFilter> Filter;

        public SelectFrom<SOOrder>
           .Where<SOOrder.status.IsEqual<SOOrderStatus.open>
               .And<SOOrder.orderType.StartsWith<TagScheduleFilter.orderType.FromCurrent>>>.View Details;
                    
       
        protected void TagScheduleFilter_OrderType_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting baseMethod)
        {
            e.NewValue = "T";
        }

        #region Dac
        [Serializable]
        [PXCacheName("TagScheduleFilter")]
        public class TagScheduleFilter : PXBqlTable, IBqlTable
        {
            [PXString]
            public abstract class orderType : PX.Data.BQL.BqlString.Field<orderType> { }
            [PXUIField(DisplayName = "OrderType", Visible = true)]
            public virtual string OrderType { get; set; }
            #endregion
        }
        #endregion

    }
}

ASPX:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/FormDetail.master" AutoEventWireup="true" ValidateRequest="false" CodeFile="CD301000.aspx.cs" Inherits="Page_CD301000" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPages/FormDetail.master" %>

<asp:Content ID="cont1" ContentPlaceHolderID="phDS" Runat="Server">
    <px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
        TypeName="MCBCustom.TagSchedule"
        PrimaryView="Filter"
        >
        <CallbackCommands>

        </CallbackCommands>
    </px:PXDataSource>
</asp:Content>
<asp:Content ID="cont2" ContentPlaceHolderID="phF" Runat="Server">
    <px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="Filter" Width="100%" Height="100px" AllowAutoHide="false">
        <Template>
            <px:PXLayoutRule ID="PXLayoutRule1" runat="server" StartRow="True"/>
        </Template>
    </px:PXFormView>
</asp:Content>
<asp:Content ID="cont3" ContentPlaceHolderID="phG" Runat="Server">
    <px:PXGrid ID="grid" runat="server" DataSourceID="ds" Width="100%" Height="150px" SkinID="Details" AllowAutoHide="false">
        <Levels>
            <px:PXGridLevel DataMember="Details">
                <Columns>
                    
                </Columns>
            </px:PXGridLevel>
        </Levels>
        <AutoSize Container="Window" Enabled="True" MinHeight="150" />
        <ActionBar >
        </ActionBar>
    </px:PXGrid>
</asp:Content>

I checked what I could from the search results on this error.  I am running version 24.108.0018.

Thank-you for any help you can provide.

Best answer by aiwan

@skalb11 

 

It may be worth introducing a parameter for the BQL query rather than a non-persisted field. 

I have had issues when trying to run a BQL query with non-persisted fields.

 

Try something like this instead

public class tConst : BqlInt.Constant<tConst>
{
public tConst() : base("T") { }
}

Then reformat your query to:

public SelectFrom<SOOrder>
.Where<SOOrder.status.IsEqual<SOOrderStatus.open>
.And<SOOrder.orderType.StartsWith<tConst>>>.View Details;

 

2 replies

  • Freshman II
  • August 7, 2025

Did you ever figure this one out? 


Forum|alt.badge.img+8
  • Captain II
  • Answer
  • August 8, 2025

@skalb11 

 

It may be worth introducing a parameter for the BQL query rather than a non-persisted field. 

I have had issues when trying to run a BQL query with non-persisted fields.

 

Try something like this instead

public class tConst : BqlInt.Constant<tConst>
{
public tConst() : base("T") { }
}

Then reformat your query to:

public SelectFrom<SOOrder>
.Where<SOOrder.status.IsEqual<SOOrderStatus.open>
.And<SOOrder.orderType.StartsWith<tConst>>>.View Details;