function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
salesforce@14salesforce@14 

How to redirect the url using the javascript?

Hi Everyone,

                  I created the custom javascript button. The issue is when i click on that button it is redirecting to the some other page which is not i am expecting, I mentioned the URLs for your reference,
for eg:
https://test--ctm--ctm.cs14.visual.force.com/apex/XXX?AAA=aC8c0000000CgQHCA0  --> This URL coming default
https://test--ctm--c.cs14.visual.force.com/apex/XXX?AAA=aC8c0000000CgQHCA0  --> I need to redirect to this URL

I am expecting to do this functionality only in javascript without using the apex class.

Thanks in Advance.
shiva pendemshiva pendem
Hi Sai ,
Use the below Line in your javascript button 

window.open('/apex/XXX?Id=aC8c0000000CgQHCA0','_blank');  

Hope it will be helpfull

Thanks,
Shiva 
salesforce@14salesforce@14
Hi Shiva,

Thanks for your response.


I used like below, but the error is coming like HYPERLINK is not defined.

HYPERLINK(
  IF(
      CONTAINS($Api.Partner_Server_URL_260, 'pra--ctmax--c.cs14.visual.force.com'), 
      'https://'+
      MID($Api.Partner_Server_URL_260, FIND( 'pra--ctmax--c.cs14.visual.force.com', $Api.Partner_Server_URL_260)-4,4)
      +'pra--ctmax--ctmax.cs14.visual.force.com',
      LEFT($Api.Partner_Server_URL_260, FIND( '/services', $Api.Partner_Server_URL_260))
  ) + Id , 'Open Record')