I have an inline vf page with 3 inputtext fields and a commandbutton on account record. Now,when i click on commandbutton it should redirect to another URL. The URL contains current loggin user id and name and current account record id and 3 field values of vf page. See below for example.


in the above URL i gave test values. vf page:

  <apex:pageBlock id="pb">
     <b> Waiver Management:  </b> 
      <apex:pageBlockSection id="pbs1" columns="6">
         <apex:inputText id="Locator" label="Record Locator"  required="true"/>
         <apex:inputtext id="First" label="FirstName" required="true" />
         <apex:inputText id="Last" label="LastName" required="true"/>
          <apex:commandButton id="WaiverButton" value="Waiver Management"  style="background:#00008B; color:white; font-size: 13px;" onclick="getNameFields()"/> 
          <!--<apex:outputfield id="userid" value="{!currentuser.Id}"/>
          <apex:outputfield id="username" value="{!currentuser.Name}"/>-->
          <!--<apex:inputcheckbox label="GSS App User"/>
          <apex:inputCheckbox label="GSS App Admin"/>-->
          <apex:param name="userid" value="{$!currentuser.PPR_ID__c}"/>
          <apex:param name="username" value="{!currentuser.name}"/>
          <apex:param name="IsAdmin" value="{!currentuser.IsAdmin__c}"/>
          <apex:param name="accountid" value="{!currentrecord.id}"/>

function getNameFields()

<!--var userid=document.getElementById('{!$Component.myForm.pb.pbs1.userid}').value;-->

    console.log('Getting Val. ');
    if(document.getElementById('{!$Component.myForm.pb.pbs1.First}').value == '')  {
            alert('Please enter First Name');

    else if(document.getElementById('{!$Component.myForm.pb.pbs1.Last}').value == '')
        alert('Please enter Last Name');




controller class: public class WaiverManagementController {

public String username { get; set; }

public String userid { get; set; }

public String getAccountId { get; set; }

public Account currentRecord{get; set;}
public user currentuser{get; set;}

public WaiverManagementController() {


//String Waiver {get;}
 PageReference redirectURL()
    PageReference myVFPage = new PageReference('https://google.com');
       // myVFPage.getParameters().put('myId', accId);
        return myVFPage;

  public void userinfo(ApexPages.StandardController cont){
     //user=(User) cont.getRecord();
     //currentuser=new User();
     currentuser=[Select Id,Name,IsAdmin__c from User where Id=:userinfo.getuserId()];


    public void getAccountId() 
        currentRecord = [SELECT Id FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')];


Can any one please help me. Which is not working for me.(may be my approach is wrong)

1 Answer 1


Use following code snippet to redirect to a particular link.

    var navigateURL;
    navigateURL = 'Your URL';   
    function isLightningExperienceOrSalesforce1() {
          `return((typeof sfo`rce != 'undefined') && sforce && (!!sforce.one));
        if( isLightningExperienceOrSalesforce1() ) {
              window.location.href = navigateURL;

  • Hi Subhasis, my issues is i want to form URL which takes those values as dynamically. if you see i tried in second else block of js function getNameFields(). But, its not forming the URL as expected. I mean user values, account id and vf page inputtext filed values to be get dynamically when its loaded.
    – svkrishna
    Jul 6, 2017 at 13:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .