Skip to main content
Question

Errors in processing screen

  • June 11, 2026
  • 9 replies
  • 44 views

Forum|alt.badge.img+1

I'm trying to create a processing screen with a filter containing an Email Account selector and a grid below showing incoming emails for the selected account.

Initially I tried using a PXProcessingJoin directly on CRSMEmail:

public PXProcessingJoin<CRSMEmail,
LeftJoin<BZPODocument, On<BZPODocument.messageID, Equal<CRSMEmail.messageId>>>,
Where<CRSMEmail.mailAccountID, Equal<Current<EMailAccount.emailAccountID>>,
And<CRSMEmail.isIncome, Equal<True>,
And<BZPODocument.messageID, IsNull>>>>
Emails;

When I set grid's DataMember to this view, I got the following error:

An unhandled exception has occurred in the function 'get_Item'. Please see the trace log for more details.
undefined: Cannot read properties of null (reading 'elemByID')

I then switched to using a PXProjection DAC based on CRSMEmail:

 [PXProjection(typeof(Select2<CRSMEmail,
LeftJoin<BZPODocument, On<BZPODocument.messageID, Equal<CRSMEmail.messageId>>>, Where<CRSMEmail.isIncome, Equal<True>, And<BZPODocument.messageID, IsNull>> >))]

public class BZCRSMEmail : PXBqlTable
{
...
}

and changed the view to:

public PXFilter<BZEmailFilter> Filter;

[PXFilterable]
public PXProcessing<BZCRSMEmail,
Where<BZCRSMEmail.mailAccountID,
Equal<Current<BZEmailFilter.emailAccountID>>>>
Emails;

Now the original error is gone, but the screen throws Object reference

I have already tried:

  • changing key fields in the projection
  • removing joins
  • using different key combinations

but the Object Reference exception remains.

Am I missing something?

9 replies

Forum|alt.badge.img+9
  • Captain II
  • June 12, 2026

@Marat43 

 

Object reference errors usually mean that the system is expecting to read a value that is not there.

Could you try to instead implement a view delegate? Have you regular PXProcessing<BZCRSMEmail> Emails;

 

Then your view delegate where you implement your filtering logic and return SelectFrom<BZCRSMEmail>.Where<BZCRSMEmail.mailAccountID.IsEqual<P.AsInt».View.Select(Base, Filter.Current.EmailAccountID);

You should perform a null check before returning, and return the unfiltered view if Filter.Current.EmailAccountID is null.


Forum|alt.badge.img+1
  • Semi-Pro III
  • June 12, 2026

Yes, the issue is most likely due to a missing or incorrect key in your projection DAC.

 

For PXProcessing to work, your projection must have a proper primary key. In this case, use NoteID from CRSMEmail and mark it as IsKey = true.

 

Example:

 

[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]

public virtual Guid? NoteID { get; set; }

 

Also, make sure to include a Selected field:

 

[PXBool]

[PXDefault(false)]

[PXUIField(DisplayName = "Selected")]

public virtual bool? Selected { get; set; }

 

And ensure your filter is correctly bound:

 

public PXFilter Filter;

 

public PXProcessing<BZCRSMEmail,

Where<BZCRSMEmail.mailAccountID,

Equal<Current<BZEmailFilter.emailAccountID>>>>

Emails;

 

Missing a key or Selected field in projection DACs commonly causes Object Reference errors in processing screens.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • June 12, 2026

@FarhanaM60 Already tried, issue still exists


Forum|alt.badge.img+1
  • Semi-Pro III
  • June 12, 2026

What is the exact issue is in your screen 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • June 12, 2026

Object reference not set to an instance of an object


Jhon Reeve Penuela
Jr Varsity II
Forum|alt.badge.img

A couple of things to add on top of ​@FarhanaM60  suggestions, since I think the root cause is in the projection itself.

1. Likely cause: a field mapped from the left-joined table. Your Where keeps only rows where BZPODocument.messageID IS NULL, so by definition every row returned has no matching BZPODocument. If your projection DAC maps any BZPODocument field — especially as a key, or anywhere it's read non-defensively — it'll be null for exactly those rows, which is a classic source of "Object reference not set." The key of a projection should always come from the primary/left table (CRSMEmail), never from the nullable right side of a LeftJoin. If you don't actually need a BZPODocument column for display, don't map any — keep the join purely for the IsNull filter.

So your key should look like this, mapped to CRSMEmail:

[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]
[PXUIField(DisplayName = "Note ID")]
public virtual Guid? NoteID { get; set; }
public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }

2. Move the filter out of the view BQL and into a delegate. Putting Current<BZEmailFilter.emailAccountID> directly in the PXProcessing Where evaluates at an awkward point in the page lifecycle (this is also why the first attempt threw the front-end elemByID error). A delegate with an explicit null guard is more reliable:

public PXFilter<BZEmailFilter> Filter;

[PXFilterable]
public PXProcessing<BZCRSMEmail> Emails;

protected virtual IEnumerable emails()
{
BZEmailFilter filter = Filter.Current;
if (filter?.EmailAccountID == null)
yield break; // nothing selected yet → show empty grid

foreach (BZCRSMEmail email in SelectFrom<BZCRSMEmail>
.Where<BZCRSMEmail.mailAccountID.IsEqual<P.AsInt>>
.View.Select(this, filter.EmailAccountID))
{
yield return email;
}
}

(The delegate name emails must match the view name Emails.)

3. One practical note: your very first error literally points you to the trace log — "see the trace log for more details." The "Object reference" message alone is hard to pin down without the stack. If the two fixes above don't resolve it, could you grab the actual stack trace from the trace log and paste it? That'll tell us exactly which field/object is null.

 

Thanks.


Forum|alt.badge.img+1
  • Semi-Pro III
  • June 12, 2026

The Object Reference error is most likely caused by a missing or incorrect key in your projection DAC.

 

For PXProcessing screens, the DAC must have a valid primary key. In your case, make sure you include NoteID from CRSMEmail and mark it as IsKey = true:

 

[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]

public virtual Guid? NoteID { get; set; }

 

Also ensure you have a Selected field:

 

[PXBool]

[PXDefault(false)]

public virtual bool? Selected { get; set; }

 

Additionally, verify that your filter is not null (BZEmailFilter.emailAccountID should have a value), as a null filter can also lead to this error.

 

Missing these is a common reason for Object Reference exceptions in processing screens using projections.


Forum|alt.badge.img+1
  • Author
  • Semi-Pro I
  • June 12, 2026

When I try to add the following field:

 
[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]
[PXUIField(DisplayName = "Note ID")]
public virtual Guid? NoteID { get; set; }

public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }

to my pxprojection:

 [Serializable]
[PXCacheName("Email Activity Projection")]
[PXProjection(typeof(Select<CRSMEmail>))]
public class BZSMEmail : PXBqlTable, IBqlTable
{
#region SMEmailNoteID
[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]
[PXUIField(DisplayName = "Note ID")]
public virtual Guid? SMEmailNoteID { get; set; }
public abstract class sMEmailNoteID : BqlGuid.Field<sMEmailNoteID> { }
#endregion

#region Selected
[PXBool]
[PXUIField(DisplayName = "Selected")]
[PXFormula(typeof(False))]
public virtual Boolean? Selected { get; set; }
public abstract class selected : BqlBool.Field<selected> { }
#endregion

}

I get the following error:

The primary DAC "BZSMEmail" of the processing view "EmailProcessing" must contain the "NoteID" field.

I also tried adding these two fields:

#region SMEmailNoteID
[PXDBGuid(IsKey = true, BqlField = typeof(CRSMEmail.noteID))]
[PXUIField(DisplayName = "Note ID")]
public virtual Guid? SMEmailNoteID { get; set; }

public abstract class sMEmailNoteID : BqlGuid.Field<sMEmailNoteID> { }
#endregion

#region NoteID
[PXNote]
public virtual Guid? NoteID { get; set; }

public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
#endregion

but it didn’t help.

I suspect the issue is related to the fact that I’m using CRSMEmail, which is a PXProjection. However, I have the same problem even when I switch to SMEmail.

I also cannot use:

public PXProcessing<SMEmail> EmailProcessing;

because SMEmail does not contain NoteID.

I also tried different approaches, for example:

public PXFilteredProcessingJoin<EMailAccount, BZEmailFilter,
InnerJoin<CRSMEmail, On<CRSMEmail.mailAccountID, Equal<EMailAccount.emailAccountID>>>,
Where<EMailAccount.emailAccountID, Equal<Current<BZEmailFilter.emailAccountID>>>> EmailProcessing;

and tried to solve it with a delegate, but nothing worked. I get object reference errors.

For PXProcessing<EMailAccount> everything works fine and there are no errors but its not what i want.

My goal is to create a screen with an email account filter, and in the grid I want to load all emails that are received for the selected email account.


Patrick Chen
Semi-Pro I
Forum|alt.badge.img+3
  • Semi-Pro I
  • June 12, 2026

I would suggest you review all the DAC and SQL definitions for your key fields and make sure they match up.