I'm using below line of code in the vf component,this is a part of repeat tag.

<td class="center"><a href="https://cs14.salesforce.com/{!o.id}/e?retURL=%2F{!o.id}">Edit</a></td>

This is working fine,but when we move to other sandbox or production then i have to replace the https://cs14 with corresponding server name.

Is there any way to fetch the values dynamically instead of changing manually. Something like "URL.getSalesforceBaseUrl()".with in the above tag?

  • 1
    why don't you use VF global variable Action.. You can directly redirect to edit page..
    – Ratan Paul
    Feb 29 '16 at 4:50
  • you are fetching value in Apex or in VF? Feb 29 '16 at 5:13
  • @user7447 try something like /apex/vfpage?id=recordId or /recordId in VF page. Feb 29 '16 at 5:47

You can use Global variable Action. Salesforce will generate URL for you. You don't have to do Anything.. This button will redirect to Account Edit page..

You just need to pass record Id

<apex:commandButton value="EDIT" action="{!URLFOR($Action.Account.Edit, Account.Id)}" />

Refer this documentation

Another option you could use this

<apex:outputLink value="{!LEFT($CurrentPage.URL,FIND('/',$CurrentPage.URL,9))+relatedto.Id+'/e?retURL=%2F'+o.Id}">Edit</apex:outputLink>

Refer this answer

  • That works only with button.In our case its an hyperlink for the Account Name and Action. Currently i'm using the url class in the backend and fetching the value onto vf template.Besides that is there any other options.
    – user7447
    Feb 29 '16 at 5:09
  • that doesn't work in my case.txs
    – user7447
    Feb 29 '16 at 5:46
  • relatedto.Id will work in case of navigating to the record page - its clear and fine. In this case i 'm using <td class="center"><a href="{!o.fullFileURL}/{!o.id}/e?retURL=%2F{!o.id}">Edit</a></td> which will navigate to the edit page and after savin returns to the record page. where fullFileURL holds the base url.
    – user7447
    Feb 29 '16 at 5:58
  • 1
    @user7447 this is just an example.. after +relatedto.Id yoiu can add /e +relatedto.Id+'/e' so this redirect to edit page..
    – Ratan Paul
    Feb 29 '16 at 5:59
  • 1
    @user7447 yes you can.. Just like this +relatedto.Id+'/e?retURL=%2F'+o.Id
    – Ratan Paul
    Feb 29 '16 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.