Solved

How to go to a URL from clicking on a Workspace item?

  • 25 October 2023
  • 6 replies
  • 154 views

Userlevel 4
Badge +1

What I am looking to do is simple, I want to have a workspace item which, when clicked, opens an external URL I specify in the same tab.

Note : I do not want the external website to be embedded in my Acumatica screen(The external website doesn’t support that).

I’ve tried several different things, but none have quite worked.

One approach I took is creating a new Screen and then adding in the below code to the aspx.cs code behind file’s  Page_Load callback. This got me very close but there is a pesky popup message when I try opening the page before the redirect happens.

    protected void Page_Load(object sender, EventArgs e)

    {

        System.Web.HttpContext context = System.Web.HttpContext.Current;
        String url = "https://www.acumatica.com";
        context.Response.Clear();
        context.Response.Write("<script language=javascript>");
        context.Response.Write(String.Format("window.open(\"{0}\",\"{1}\");", url, "_top"));

        context.Response.Write("</script>");
        context.Response.Cache.SetNoStore();
        context.Response.Cache.SetNoServerCaching();
        context.Response.End();
    }

Here is the problem popup message I’m seeing

After I click okay the correct screen then opens up. Also the above message doesn’t always popup, it seems to popup every other time I click on the Workspace item for some strange reason.

If anyone has any suggestions I’d appreciate your thoughts,

Philip Engesser

icon

Best answer by Mike Gifford 30 October 2023, 18:26

View original

6 replies

Userlevel 4
Badge

I think you were close - looking more at Sergeys article http://asiablog.acumatica.com/2017/06/redirect-on-page-load.html

 

I think you just had some things missing?

    protected void Page_Load(object sender, EventArgs e)

    {

       System.Web.HttpContext context = System.Web.HttpContext.Current;
       String url = "http://acumatica.com";
       Boolean iscallback = context.Request.Form["__CALLBACKID"] != null;
       Boolean isget = String.Equals(context.Request.HttpMethod, "GET", StringComparison.InvariantCultureIgnoreCase);
       Boolean ispost = String.Equals(context.Request.HttpMethod, "POST", StringComparison.InvariantCultureIgnoreCase);
       context.Response.Clear();
       if (iscallback)
       {
              context.Response.Write("eRedirect0:" + url);
       }
       else if (isget || ispost)
       {
        context.Response.Clear();
      context.Response.Write("<script language=javascript>");
        context.Response.Write(String.Format("window.open(\"{0}\",\"{1}\");", url, "_top"));
              context.Response.Write("</script>");
       }
       context.Response.Cache.SetNoStore();
       context.Response.Cache.SetNoServerCaching();
       context.Response.End();
    }

Userlevel 4
Badge +1

Hi Mike,

Thanks for the suggestion. I did try the full code snippet from Sergeys article but unfortunately that also did not work for me. The code I posted was just a slimed down version to make understanding the question easier.
If you tried the above code and it worked then let me know, because maybe I messed something up. Otherwise thanks for the suggestion but it doesn’t quite do what I was looking for.

Userlevel 4
Badge

Hi - yes i tried it and it worked. I created a new dummy page/graph and put that code into the page_load - worked fine for me.

 

With yours i got the same error that you did.

Userlevel 4
Badge

I added a customization attachment that should work - i did it on 23r1..

Userlevel 4
Badge +1

Hi @Mike Gifford,

I appreciate the help and customization to try out. A bunch of work recently came down the pipeline so depending on how that goes it might take me a bit to follow up on this. I just wanted to let you know that this is still very much on my to do list!

Sorry about the delay,

Philip Engesser

Userlevel 4
Badge +1

@Mike Gifford I gave your code a try and it worked!
I’m not sure what I was doing wrong, I thought I had already tried that, but I must have messed it up somehow 😅

Thanks for your help and for being persistent when I had doubts that it would work!

Philip Engesser

Reply


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