Skip to main content

Getting Current User Details via Modern UI

  • July 30, 2026
  • 1 reply
  • 17 views

Forum|alt.badge.img+9

Hello Everyone,

 

I recently stumbled onto the requirement of injecting current user data into HTML to render it as an iframe within the Modern UI.

 

It took me a while (and some AI assistance) to get there so I thought I would share the approach I took.

 

Firstly, in the Classic UI, you can do this via the PageLoad event in the .aspx.cs file. The easiest way that I found with the Modern UI was to have a custom .ashx IHttpHandler in /Frames and which is called via fetch() within the activate() method that Aurelia uses.

 

TS:

export class CO301000 extends PXScreen {
MasterView = createSingle(MasterViewClass);
iframeSrc: string = "about:blank";

async activate(): Promise<void> {
const app = window.location.pathname.split("/").filter(Boolean)[0];

const siteRoot = window.location.origin + (app ? "/" + app : "");
const userUrl = siteRoot + "/Frames/User.ashx";

try {
const res = await fetch(userUrl);

const [username] = await res.text();
if (!username) {
console.error("Username not found");
return;
}

this.iframeSrc = siteRoot + "/Endpoint" +
"?user=" + encodeURIComponent(username);
} catch (e) {
console.error("Username: " + userUrl + " failed", e);
}
}
}

.ashx:

public void ProcessRequest(HttpContext context)
{
var username = context.User?.Identity?.Name;

context.Response.ContentType = "text/plain";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.Write(username ?? " ");
context.Response.Flush();
}

 

If anyone has any better ways to do this, please let me know!

1 reply

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

Since ASHX is part of the ASP.NET family, I suspect this will stop working when Acumatica moves away from ASP.NET.

I don’t think I’m fully understanding your use-case because I’m confused in what situation this would be necessary. Why couldn’t you place a field on the screen and update the content from the graph?