Skip to main content
Question

Object reference not set to an instance of an object for Selector inside SmartPanel

  • February 26, 2026
  • 13 replies
  • 81 views

Hello, i don’t know if this is a complicated problem or if i’m just thinking in the wrong direction. I have a Dialog which pops out per button click. Inside this SmartPanel i have 2 Selectors which aren’t working. I tried using Standard ones which are working in other Screens, but i get the same error.

 

I have a Filter DAC CommSupplier, inside this DAC is a Checkbox and the 2 Selectors. 

This is how i open the Dialog:
 

     public PXFilter<CommSupplierFilter> CommSupplierFilter;
public PXAction<FSServiceOrder> commSupplier;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Lieferanten beauftragen", MapEnableRights = PXCacheRights.Select)]
protected IEnumerable CommSupplier(PXAdapter adapter)
{
if (Base.CurrentServiceOrder.Current == null)
return adapter.Get();
if(Base.ServiceOrderRecords.Current == null)
return adapter.Get();

if (CommSupplierFilter.Current == null)
{
CommSupplierFilter.Insert(new CommSupplierFilter());
}

CommSupplierFilter.Cache.Clear();
CommSupplierFilter.Insert(new CommSupplierFilter());

if (CommSupplierFilter.AskExt() == WebDialogResult.OK)
{
return adapter.Get();
}

return adapter.Get();
}

Here is the SmartPanel aspx code:

</px:PXSmartPanel>
<px:PXSmartPanel runat="server" ID="AG_CommSupplier_Dialog" Caption="Lieferanten Beauftragen" CaptionVisible="True" LoadOnDemand="True" AcceptButtonID="AG_CommSuppliert_Button1" CancelButtonID="AG_CommSuppliert_Button2" Key="CommSupplierFilter" AutoRepaint="True">
<px:PXFormView runat="server" ID="AG_CommSupplier_PopUp" Caption="Lieferanten Beauftragen" DataMember="CommSupplierFilter" Width="100%" Visible="True" DataSourceID="ds">
<Template>
<px:PXCheckBox runat="server" ID="AG_CommSupplier_Checkbox1" DataField="ApplyToAll" Text="Alle Positionen" />
<px:PXSelector runat="server" ID="CstPXSelector32" DataField="Group" />
<px:PXSelector runat="server" ID="CstPXSelector33" DataField="VendorID" /></Template></px:PXFormView>
<px:PXPanel runat="server" ID="AG_commSupplierPanel">
<px:PXButton runat="server" ID="AG_CommSuppliert_Button1" DialogResult="OK" Text="OK" />
<px:PXButton runat="server" ID="AG_CommSuppliert_Button2" DialogResult="Cancel" Text="Cancel" /></px:PXPanel></px:PXSmartPanel>

And here is the Code of my Filter DAC:
 

{
[PXCacheName("Comm Supplier Filter")]
[PXSerializable]
public class CommSupplierFilter : PXBqlTable, IBqlTable
{
#region ApplyToAll
public abstract class applyToAll : PX.Data.BQL.BqlBool.Field<applyToAll> { }

[PXBool]
[PXUIField(DisplayName = "Alle Positionen")]
[PXDefault(true)]
public bool? ApplyToAll { get; set; }
#endregion

#region Group
public abstract class group : PX.Data.BQL.BqlInt.Field<group> { }

[PXInt]
[PXUIField(DisplayName = "Gruppe")]
//[PXSelector(
// typeof(Search<FSSODetExt.usrGroupNr,
// Where<FSSODet.srvOrdType, Equal<Current<FSServiceOrder.srvOrdType>>,
// And<FSSODet.refNbr, Equal<Current<FSServiceOrder.refNbr>>,
// And<FSSODetExt.usrGroupNr, IsNotNull>>>>),
// typeof(FSSODetExt.usrGroupNr),
// DescriptionField = typeof(FSSODetExt.usrGroupNr))]
[PXSelector(typeof(Search<PMProject.contractID>),
typeof(PMProject.contractCD),
typeof(PMProject.description),
typeof(PMProject.customerID),
typeof(PMProject.status),
SubstituteKey = typeof(PMProject.contractCD), DescriptionField = typeof(PMProject.description), CacheGlobal = true, ValidateValue = false)]

public int? Group { get; set; }
#endregion

#region VendorID
public abstract class vendorID : PX.Data.BQL.BqlInt.Field<vendorID> { }

[PXInt]
[PXUIField(DisplayName = "Lieferant")]
[PXSelector(
typeof(SelectFrom<VendorR>
.LeftJoin<Address>.On<
Address.bAccountID.IsEqual<VendorR.bAccountID>
.And<Address.addressID.IsEqual<VendorR.defAddressID>>>
.SearchFor<VendorR.bAccountID>),
typeof(VendorR.acctCD),
typeof(VendorR.acctName),
typeof(Address.addressLine1),
typeof(Address.postalCode),
typeof(Address.city),
SubstituteKey = typeof(VendorR.acctCD),
DescriptionField = typeof(VendorR.acctName),
Filterable = true,
ValidateValue = false)]
public virtual int? VendorID { get; set; }
#endregion

}
}

And this is the Error i get:
 


at PX.Data.PXFirstChanceExceptionLogger.ProfilerFirstChanceException(Object o, FirstChanceExceptionEventArgs args)
at PX.Web.UI.PXGrid.PerformSelect()
at PX.Web.UI.PXSelectorBase.GetCallbackResult(PXCallbackCommand cmd)
at PX.Web.UI.PXCallbackManager.RenderControlsData(PXCallbackResultMethod resultMethod, XmlWriter writer)
at PX.Web.UI.PXCallbackManager.GetCallbackResultInternal(PXCallbackResultMethod resultMethod)
at PX.Web.UI.PXCallbackManager.GetCallbackResult(PXCallbackResultMethod resultMethod)
at System.Web.UI.Page.RenderCallback()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at PX.Web.UI.PXPage.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

 

I’d appreciate any help. If anything else is needed i’d be happy to share it.

 

Thanks 


Best Regards

Rayen

13 replies

Forum|alt.badge.img
  • Jr Varsity II
  • February 26, 2026

The error usually happens because the SmartPanel view or its Current record is null when the selector loads.

 

Before opening the SmartPanel, make sure the view is initialized:

 

if (MyView.Current == null)

{

MyView.Current = MyView.Insert();

}

 

Also verify that any Current<> references used in the selector have values. In most cases, the issue is caused by the parent record not being initialized before the panel opens.


  • Author
  • Freshman I
  • February 26, 2026

@FarhanaM60 Thanks for your reply, sadly i already have this built in

         if (CommSupplierFilter.Current == null)
{
CommSupplierFilter.Insert(new CommSupplierFilter());
}
CommSupplierFilter.Cache.Clear();
CommSupplierFilter.Insert(new CommSupplierFilter());

and both my selectors aren’t referring to any parent nor Current.
 

        [PXSelector(typeof(Search<PMProject.contractID>),
typeof(PMProject.contractCD),
typeof(PMProject.description),
typeof(PMProject.customerID),
typeof(PMProject.status),
SubstituteKey = typeof(PMProject.contractCD), DescriptionField = typeof(PMProject.description), CacheGlobal = true, ValidateValue = false)]


[PXSelector(
typeof(SelectFrom<VendorR>
.LeftJoin<Address>.On<
Address.bAccountID.IsEqual<VendorR.bAccountID>
.And<Address.addressID.IsEqual<VendorR.defAddressID>>>
.SearchFor<VendorR.bAccountID>),
typeof(VendorR.acctCD),
typeof(VendorR.acctName),
typeof(Address.addressLine1),
typeof(Address.postalCode),
typeof(Address.city),
SubstituteKey = typeof(VendorR.acctCD),
DescriptionField = typeof(VendorR.acctName),
Filterable = true,
ValidateValue = false)]


Is there maybe something wrongly configured in the aspx?


Forum|alt.badge.img
  • Jr Varsity II
  • February 26, 2026

If you have modified something in the existing setup, it would be better to remove the UI Selector and add it again.

Also, could you please let me know in which context the error is occurring?


  • Author
  • Freshman I
  • February 26, 2026

@FarhanaM60 I added a button which triggers this PopUp Smart Panel inside the FS300100 Screen in the Details tab. The error occurs when i click on the lens symbol of the Selector, so when i want to “open” the Selector. I can share a screenshot of the project editor dialog setup if it helps.

I’ve tried removing the Selectors from the Panel and add them again, but that didn’t help if you mean this.


Forum|alt.badge.img
  • Jr Varsity II
  • February 26, 2026

The issue usually occurs because the SmartPanel view (or its Current record) is not initialized when the selector lookup is opened.

 

Make sure to initialize the view before opening the SmartPanel (e.g., insert or set View.Current). Also verify that any Current<> references used in the selector are not null.


darylbowman
Captain II
Forum|alt.badge.img+16

In similar situations in the past, I’ve found this method of initialization to be the most effective:

if (EscalationDialog.AskExt(
(graph, view) =>
{
EscalationDialog.Cache.ClearQueryCache();
EscalationDialog.View.Clear();
EscalationDialog.Cache.Clear();
EscalationDialog.Current = new ISEscalationActivity()
{
WorkgroupID = depotWorkgroup?.WorkGroupID
};
}, true) != WebDialogResult.OK)
return adapter.Get()

// Do stuff with the result

 


  • Author
  • Freshman I
  • February 26, 2026

In similar situations in the past, I’ve found this method of initialization to be the most effective:

if (EscalationDialog.AskExt(
(graph, view) =>
{
EscalationDialog.Cache.ClearQueryCache();
EscalationDialog.View.Clear();
EscalationDialog.Cache.Clear();
EscalationDialog.Current = new ISEscalationActivity()
{
WorkgroupID = depotWorkgroup?.WorkGroupID
};
}, true) != WebDialogResult.OK)
return adapter.Get()

// Do stuff with the result

 

        protected IEnumerable CommSupplier(PXAdapter adapter)
{
if (Base.CurrentServiceOrder.Current == null)
return adapter.Get();

var result = CommSupplierFilter.AskExt(
(graph, view) =>
{

CommSupplierFilter.Cache.ClearQueryCache();
CommSupplierFilter.View.Clear();
CommSupplierFilter.Cache.Clear();

var row = (CommSupplierFilter)CommSupplierFilter.Cache.CreateInstance();
row.ApplyToAll = true;

row = CommSupplierFilter.Insert(row);
CommSupplierFilter.Current = row;
},
true);

if (result != WebDialogResult.OK)
return adapter.Get();

var filter = CommSupplierFilter.Current;
if (filter == null)
return adapter.Get();


return adapter.Get();
}

I’ve tried this solution but i still get the same error. 


darylbowman
Captain II
Forum|alt.badge.img+16

Could you narrow down if just one of the selectors is causing the issue by removing the other? I’m suspicious of the joins in VendorID. Could you remove that one and see if you get a different result?


  • Author
  • Freshman I
  • February 26, 2026

@darylbowman I get the error on both selectors, i’ve tried removing the vendorID one and keep the simple PMProject one (i copied this one from a working screen). Everytime i get the same error.

Is there anything else i can share to come to a solution?


darylbowman
Captain II
Forum|alt.badge.img+16

I honestly don't see anything that should cause an error. Have you tried restarting the application (from the ‘Apply Updates’ screen)?


  • Author
  • Freshman I
  • February 26, 2026

@darylbowman i’ve never done that, where exactly would i do that 😅 Sorry im only currently a junior 


darylbowman
Captain II
Forum|alt.badge.img+16

... (from the ‘Apply Updates’ screen)?

 


Forum|alt.badge.img+8
  • Captain II
  • February 26, 2026

I’m curious about the Insert call.

Daryl’s code isn’t specifically calling insert, and looking in my code, I’m not either.

Daryl wrote in his example this, with no insert:

EscalationDialog.Cache.ClearQueryCache();
EscalationDialog.View.Clear();
EscalationDialog.Cache.Clear();
EscalationDialog.Current = new ISEscalationActivity()
{
WorkgroupID = depotWorkgroup?.WorkGroupID
};

Can you try removing your .Insert call on the filter view?

Also, your DAC is not decorated with [PXVirtual]