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
hramanihramani 

How do i pass the id of one vf page to another?

I have a vf page named 'TYRINPOUP' which has the below statement which onlick opens another vf named 'twovalues'.

 

<apex:commandButton value="Search" onclick="window.open('/apex/twovalues','','width=800,height=500');" action="{!testing}" rerender="panel"/>

 

i need to pass the id of the current vf (TYRINPOUP) to the other vf 'twovalues'

Pls help

Arunkumar.RArunkumar.R

What ID do you want to Pass either record ID or ? can you explain clearly?

hramanihramani

I need to pass the record id.  TYRINPOUP is a inline vf present on the record detail page and contains a button. onclick of this button it should open another vf named 'twovalues' where the record id of  TYRINPOUP  should be passed.

Arunkumar.RArunkumar.R

In your Apex class declare variable as

 

Public string recordId{get;set;}

 

To Get your current page record ID in declare this in your constructor,

 

recordID = ApexPages.CurrentPage().getparameters().get('id');

 

 

In your visualforce page add this in your command button

 

<apex:commandButton value="Search" onclick="window.open('/apex/twovalues?recordID','','width=800,height=500');" action="{!testing}" rerender="panel"/>

 

If you found this answer helpful to you... Please accept this as a Solution and  give kudos by clicking on the star icon.

 

Thanks and Regards,

Arunkumar.R | Salesforce Certified Developer

 

 

 

 

Arunkumar.RArunkumar.R

If you use both onclick on action in a command button either one only will excute, you can use oncomplete instead of onclick..

 

Else,

 

You can pass id through in your pageReference method

 

 

public PageReference testing() {

PageReference pageref= new pagereference('/apex/twovalues?recordID');
pageref.setRedirect(true);
return pageref;
}
}

hramanihramani

I tried this but I'm not able to pass the id , it is throwing up the below error (in bold)

 

 

List has no rows for assignment to SObject

Error is in expression '{!testit1}' in component <apex:page> in page shelfnodiplay1

 

 

An unexpected error has occurred. Your development organization has been notified.     

 

 

below are the statement i used

 

 

CONTROLLER: 

 

public class callout1{

public string recordid{get;set;}

public callout1 (ApexPages.StandardController controller) {
recordid = ApexPages.currentPage().getParameters().get('id');


}}

 

PAGE:

 

<apex:page showHeader="false" standardcontroller="Business_Unit__c" extensions="callout1">
<apex:form >


<apex:pageBlock >
<apex:pageBlockButtons >
<apex:pageblockSection >
<apex:outputPanel id="panel">
<apex:commandButton value="Search" onclick="window.open('/apex/shelfnodiplay1?recordid','','width=800,height=500');" rerender="panel"/>
<br/>

</apex:outputPanel>

</apex:pageblockSection></apex:pageBlockButtons> </apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Pls help

digamber.prasaddigamber.prasad

Hi,

 

Try change command button onclick like below:-

 

<apex:commandButton value="Search" onclick="window.open('/apex/shelfnodiplay1?recordId={!recordid}','','width=800,height=500');" rerender="panel"/>

 Let me know if it doesn't work for you!

 

Regards,

Digamber Prasad

Arunkumar.RArunkumar.R

 

Please modify your command button ...

 

<apex:commandButton value="Search" onclick="window.open('/apex/CreateCase?{!recordid}','','width=800,height=500');" rerender="panel"/>

 

 

Hope this will works for you.. Let me know if you have any issue...!

 

If this works please mark this as a solutions and give kudos...