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
KaityKaity 

How to set Dynamic URL of Salesforce in Apex.

HI,
On clicking a custom Tab, user should be redirected to one of the custom settings. The code is as below:
I want to make the URL as dynamic sothat i need to change the URL(https://ABC-INT.cs18.my.salesforce.com/). Please suggest.
public with sharing class ActivitiesController {
    public PageReference redirect() {
        return new PageReference('https://ABC-INT.cs18.my.salesforce.com/setup/ui/listCustomSettingsData.apexp?com.salesforce.visualforce.ViewStateCSRF=VmpFPSxNakF4TmkweE1TMHdORlF3T1Rvd05Eb3pOQzR5TkROYSxFbVV1SDVydmdzTXJnXzNWNXFTdjZhLE56RTNPVGcz&com.salesforce.visualforce.ViewStateVersion=201610312000010466&CS_Defn_View%3ACS_View=CS_Defn_View%3ACS_View&CS_Defn_View%3ACS_View%3AtheDetailBlock%3AdetailButtons%3Amanage=Manage&id=a1V&retURL=%2Fsetup%2Fui%2FviewCustomSettings.apexp%3Fsetupid%3DCustomSettings%26id%3D01I11000000AdEY');
    }
}
Sukesh Kumar 33Sukesh Kumar 33
Call the redirect on action of vf page and store the URL in a custom setting
KaityKaity
Hi Sukesh,
I donot want to change the URL manually when deployment or migration happened as a post migration activity. I want,  based upon the dynamic change in URL  my code should also work fine.

Is there any such technique there? Appreciate your help. Thanks!
-Kaity
KaityKaity
Hi Sukesh,
Do you have the sample code for this..please?
I am using the below one. It is not working

<apex:page action="{!URLFOR($Resource.myStsticResourceURL)}"/>

Thanks!