Skip to main content
Question

Trying to refresh the grid on Incoming Documents (AP301110) after adding or updating a Note

  • Nov 27, 2026 5:01 PM UTC
  • 5 replies
  • 56 views
  • Translate All

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

The customer wants to show the text in a custom field on the grid of the AP301110 Incoming Documents screen.  This saves them from having to open the note on each row to inspect the note text.

I add a custom unbound field UsrNote to the grid.

When the screen is loaded or refreshed, it displays the note text properly.

 

When you open the note and change it to Joe2 and click OK, it saves the note, but the value on the grid is not updated.

I think the goal is to click the Refresh action on the screen after you click OK on the Note popup.

Since this is a processing screen, the persist to the DB happens outside of the events that are firing in the IncomingDocumentsProcess graph, and no events are fired on the graph extension. 

After you click OK on the note, no events fire on the graph other than RowSelected.  If I try to get the new value saved in the DB on that event, it just brings up the previous notetext value, not the new value.

I am using the FieldSelecting event to get the DB value for the current record and set the custom field to the NoteText value.  This works correctly.

What can I do on this graph extension to cause the screen to refresh when the note is saved to the DB?  The RowPersisted on Note table is not fired.

I’ve tried hundreds of things to try to catch the update to the Note that was saved but I cannot find any way to do it.

Here is my code at this time.  I’ve left off the hundreds of commented out lines that did not work.

	public class IncomingDocumentsProcess_Extension : PXGraphExtension<IncomingDocumentsProcess>
{

protected virtual void _(Events.RowPersisted<Note> e)
{
if (e.Row == null || e.TranStatus != PXTranStatus.Completed) return;

// Only react to inserts or updates
if (e.Operation != PXDBOperation.Insert && e.Operation != PXDBOperation.Update)
return;

Note updatedNote = e.Row;

// Find the matching grid row in IncomingDocumentsProcess
// Note: Check the exact view name in your version (commonly Base.Records)
RecognizedRecord matchingRow = Base.Records.Select()
.RowCast<RecognizedRecord>()
.FirstOrDefault(r => r.NoteID == updatedNote.NoteID);

if (matchingRow != null)
{
// Your custom logic here (e.g., updating a custom flag or refreshing the grid)
Base.Records.Cache.SetValueExt<SCGCRecognizedRecordExt.usrNote>(matchingRow, true);
Base.Records.View.RequestRefresh();
}
}

//return current value to the custom field in the grid
//works properly
protected virtual void _(Events.FieldSelecting<RecognizedRecordForProcessing, SCGCRecognizedRecordExt.usrNote> e)
{
var row = (RecognizedRecordForProcessing)e.Row;
if (row == null) return;

string noteText = PXNoteAttribute.GetNote(e.Cache, e.Row);
if (noteText == null) return;
e.ReturnValue = noteText;
}

//HUNDREDS of lines below here that are commented out

 

5 replies

Forum|alt.badge.img+5

Hello ​@Joe Schmucker I tried several approaches as well and came up with this workaround. You need to make the following changes:
 

1. Graph Extension Changes (as you said already working)

  • Add FieldSelecting event for the unbound UsrNote field.

  • Retrieve the latest note text directly from the Note table using the record's NoteID.

  • Assign the retrieved text to e.ReturnValue.

  • This ensures the grid displays the latest note whenever the field is selected or refreshed.

2. ASPX.cs Changes

  • Find the grid control recursively because it is inside the MasterPage's ContentPlaceHolder.

  • Subscribe to the grid's NoteSave event.

  • When the user clicks OK in the Note dialog:

    • Get the updated note text from ev.Note.

    • Escape special characters for JavaScript.

    • Use PXCallbackManager.RegisterJavaScript to update the UsrNote cell.

    • Call grid.refresh() after a short delay.

I hope this help.
 

Translate

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

​@Abhishek Niikam You are awesome!

I’ve never done javascript on an ASPX page other than in Classic UI.  I honestly don’t know how to do what you recommended for MUI.  Is this done in the frontend MUI file?  If you could show me the code you used to do your test I would be willing to pay you for it.  

Also, thank you SO MUCH for taking the time to actually do this and show it in the video.  That was mad fresh!

Translate

Forum|alt.badge.img+5

Hi ​@Joe Schmucker , sorry, I missed your notification!

Here’s what I’ve implemented along with my code. It’s working in both Classic UI and Modern UI.

In the graph extension, use the FieldSelecting event to fetch the latest note text directly from the Note table and assign it to the unbound UsrNote field.

This ensures the grid displays the latest note whenever the field is selected, including after the grid refresh.(I’m, assuming your event already working properly)

ASPX Page Code-Behind (.aspx.cs)

To refresh the unbound UsrNote column immediately after the user saves the note using the built-in Note icon, attach to the grid's NoteSave event in the ASPX page code-behind.

Since the grid is nested inside an ASP.NET MasterPage (ContentPlaceHolder), use recursive FindControl to locate the grid.

Code (.aspx.cs):


using System;
using System.Web.UI;
using PX.Web.UI;

public partial class Page_TS609090 : PX.Web.UI.PXPage
{
private bool _hooked = false;

protected void Page_Init(object sender, EventArgs e)
{
HookGrid();
}

protected void Page_Load(object sender, EventArgs e)
{
HookGrid();
}

private void HookGrid()
{
if (_hooked) return;

var g = FindControlRecursive(this, "grid") as PXGrid;

if (g != null)
{
_hooked = true;

g.NoteSave += (s, ev) =>
{
string safeNote = (ev.Note ?? "")
.Replace("\\", "\\\\")
.Replace("'", "\\'")
.Replace("\r", "\\r")
.Replace("\n", "\\n");

string script =
"(function() {" +
" var g = null;" +
" try {" +
" if (typeof __px_all === 'function') g = __px_all(window)['" + g.ClientID + "'] || __px_all(window)['" + g.ID + "'];" +
" if (!g && window.px_alls) {" +
" g = px_alls['" + g.ClientID + "'] || px_alls['" + g.ID + "'];" +
" if (!g) { for (var k in px_alls) { if (k === 'grid' || k.indexOf('_grid') >= 0) { g = px_alls[k]; break; } } }" +
" }" +
" } catch(e) {}" +
" if (g) {" +
" try {" +
" if (g.activeRow) {" +
" var c = g.activeRow.getCell('UsrNote');" +
" if (c) {" +
" if (typeof c.setValue === 'function') c.setValue('" + safeNote + "');" +
" if (c.element) {" +
" var span = c.element.querySelector('.text');" +
" if (span) span.innerText = '" + safeNote + "';" +
" else c.element.innerText = '" + safeNote + "';" +
" }" +
" }" +
" }" +
" } catch(e) {}" +
" if (typeof g.refresh === 'function') {" +
" setTimeout(function() { g.refresh(); }, 50);" +
" }" +
" }" +
"})();";

PXCallbackManager.RegisterJavaScript(script);
};
}
}

private Control FindControlRecursive(Control root, string id)
{
if (root == null) return null;

if (string.Equals(root.ID, id, StringComparison.OrdinalIgnoreCase))
return root;

foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null) return t;
}

return null;
}
}

Key points:

  • HookGrid() locates the grid recursively because it is inside the MasterPage.

  • NoteSave executes when the user saves the note through the built-in Note dialog.

  • PXCallbackManager.RegisterJavaScript() updates the UsrNote cell and triggers a grid refresh.

  • The grid refresh executes FieldSelecting again to retrieve the latest note text.
     

Feel free to reach out if you have any questions. I hope this helps!

Translate

Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • Dec 2, 2026 6:03 PM UTC

​@Abhishek Niikam 

WOW.  That is so over my head.  Thank you so much for providing me with your work!

I created a new class file and put that code in it.  It does not fire in debug.  I changed the code from Page_TS609090 to Page_AP301110 as that is the page I am working on. I thought that might be the issue.  That does not fire in debug either.  

This is so over my head that I wouldn’t know what to check for.  Sorry for being a pain on this.  

In my graph extension, I am getting the value to show as follows:

        protected virtual void _(Events.FieldSelecting<RecognizedRecordForProcessing, SCGCRecognizedRecordExt.usrNote> e)
        {
            var row = (RecognizedRecordForProcessing)e.Row;
            if (row == null) return;

            string noteText = PXNoteAttribute.GetNote(e.Cache, e.Row);
            if (noteText == null) return;
            e.ReturnValue = noteText;
        }

Maybe the getNote is returning the previously cached value?  Either way, I think I should hit the code in debug (the code you provided).

 

 

 

 

Translate

KrunalDoshi
Pro III
Forum|alt.badge.img+9
  • Pro III
  • Dec 2, 2026 6:11 PM UTC

I don’t think you need to create a new class file unless I am missing something. Rather modify the existing one.

 

Translate