Embed iFrame or Webpage via Code

  • 2 April 2024
  • 2 replies

Userlevel 4
Badge +1


I am trying to embed a webpage into a tab item on an existing screen but it is not working. I am trying two different ways based on some code snippets I found. The first, utilizes standard containers and redirect exceptions (Redirect Option). The code gets validated but every time I go to check the output, I get the following:

I checked to ensure that the website is iFrame compatible and it is so I am not sure why I am getting this if it has worked for others. Below is my code, very simple..

using System;
using PX.Data;

namespace SampleiFrame
public class SampleIFrame : PXGraph<SampleIFrame>

public SampleIFrame()
throw new Exception("Redirect:https://**WEBSITE**.com$target=main");


The other option is to just modify the aspx directly since I don’t need any standard containers. I followed the following code (ASPX Option). I haven’t been able to make this work in the validation stage because every time I update the aspx and regenerate, it erases my code.

I feel like I’m missing something super obvious in both scenarios.. any help would be much appreciated. Thanks so much!


Best answer by Marco Villasenor 3 April 2024, 03:41

View original

2 replies

Userlevel 3
Badge +2

The original article that proposed this method is this one.

As you can see, the there are several values to use. In your case you would use 0 like this Redirect0, but I guess that is the default as it works the same without it.

throw new Exception("Redirect0:https://**WEBSITE**.com$target=main");

I got this to work with an action button but not in the constructor of the Graph.

The special “Redirect” exception generates a message that is handled by JavaScript in the Acumatica frontend UI, but it looks like the Graph is not ready yet to handle it in the constructor, thus resulting in a standard Exception error message. Looks like we just need to find the right moment or event from where we can trigger the Exception.

Take note though, that due to security issues and stability of software, redirect to external web site in the iframe is forbidden in Acumatica (as confirmed in that same article), so this is not an official method or best practice and is subject to change, which could break your customization in the future.

I did find an alternative method in another (old) article using a blank page and the Page_Load method, but I haven’t been able to test it yet.


Userlevel 4
Badge +1

Hey @Marco Villasenor- I appreciate the insight. I put the redirect in an action instead of the constructor and it worked. In my reading, it seems that the redirect has to be wrapped in an action due to some catch statements working in the background- not going to pretend like I know, but it works for me as a reason why it works one way and not the other. With that being said, I tried calling the action from within the constructor and as I expected that also didn’t work. From my reading, that makes us rely on ASPX and JS logic to execute. I was able to locate this article: Redirect Conditionally on Page Load. I got it to work.. the problem is that there is a 1 second lag where you see the dummy base screen before it loads.. so it doesn’t look professional. Probably need to polish it up but I appreciate the insight.


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved