0

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.

http://prbi11.xyz.com:17063/GSSWaiverWeb/accountdetails.html?userId=1000123&fullName=Test&isAdmin=Y&accountId=33904194&pnrNumber=&firstName=&lastName=&isFromStart=true

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}"/>
      </apex:pageBlockSection>
   </apex:pageBlock>

    <script>
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');
        }
       else{

          <!--window.open('http://prbi11.delta.com:17063/GSSWaiverWeb/accountdetails.html?userId=12345&fullName=FullName&isAdmin=Y&accountId=33904194&pnrNumber=&firstName=&lastName=&isFromStart=true')-->
           <!--window.open('http://prbi11.delta.com:17063/GSSWaiverWeb/accountdetails.html?userid={!currentuser.id}&fullName={!currentuser.Name}&IsAdmin=Yes&AccountId={!currentrecord.Id}&pnrnumber=Locator.value&firstname=First.value&lastname=Last.value)-->
          <window.open('http://prbi11.delta.com:17063/GSSWaiverWeb/accountdetails.html?userid=userid.value&fullName=username.value&IsAdmin=IsAdmin.value&AccountId=accountid.value&pnrnumber=Locator.value&firstname=First.value&lastname=Last.value)

}

}
</script>

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.setRedirect(true);
       // 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)

0

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() ) {
              sforce.one.navigateToURL(navigateURL);
        }
        else{
              window.location.href = navigateURL;


}
| improve this answer | |
  • 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 '17 at 13:37

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.