Question

Reference external URL in Pega portal current window in Pega 7.2.2

Hi All-

I am trying to use 'Open URL In Window' in the section rule to launch the external URL from pega portal. Instead of opening up in a separate window, I wanted to launch the external page in the same window. I tried by passing the parameter window name as "_self", but am getting error.

Can you please suggest how I can achieve this functionality?

Appreciate your responses!

Comments

Keep up to date on this post and subscribe to comments

Pega
September 14, 2019 - 6:53am

Hi, 

You can use window.location.replace () function in Javascript to open in the same window.

Try calling Run script on the button and give any function name. 

In userworkform, define the function. 

function testfunc(){
window.location.replace("https://stackoverflow.com/questions/8293983/how-to-use-window-location-replace-javascript");
  }

If it doesn't work , try this code:

function testfunc(){
parent.window.location.replace("https://stackoverflow.com/questions/8293983/how-to-use-window-location-replace-javascript");
  }

 

Thanks

Pega
September 15, 2019 - 11:15pm

Hi

Can you share your configuration and also the error you are receiving? 

Thanks, Elisha

Pega
September 16, 2019 - 5:48am

Hi ,

Could you please try the below configuration .It is working at my end.

1.Place the below code in userWorkForm

<script>

function openUrl(){
    var myURL = window.open('https://google.com', '_top');
    
  }
</script>

2.Go to the button action set and for onclick event configure runscript action with openUrl method

Pega
September 16, 2019 - 8:56am
Response to bathb

Thanks, yes it does.  I think, only caveat is, you will lose the main window (Pega Application window) with '_top'.

You may want to use '_new' instead of '_top' and the link will be opened in a new tab.

<script>

function openUrl(){
    var myURL = window.open('https://google.com', '_new');
    
  }
</script>

Thank you

September 16, 2019 - 1:21pm
Response to tanie_GCS

Thank you for your response. I tried with _new also and it is opening up in new tab instead of opening in my current panel of the harness screen.

September 16, 2019 - 1:16pm
Response to bathb

Thanks so much for your response. Yes, it worked and replaced my entire window. And I cannot go back if my whole window is replaced. I am having my main harness screen divided into 3 panels: 'Header Panel' and below it 'Left Panel' and 'Right Panel'. I only wanted the new URL to be opened in my right panel, when I click the link from the left panel. Is there a way I can achieve this?

 

Pega
September 17, 2019 - 6:38am
Response to prathimak4186

Hi  Prathima,

Have you tried the below script ..

<script>

function openUrl(){
    var myURL = window.open('https://google.com', '_self');
    //myURL.location;
  }
</script>

It should reload in the same frame.

September 16, 2019 - 9:26am

Hi , 

 

Just curious why you would want to replace your Pega application with an external page. Do it only if you do not want to return to Pega. In the event you do, there is no guarantee that Pega application will be "preserved"  at the same state.