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
Abhishek patil 26Abhishek patil 26 

how to take id of current inserted record from vf page and i need to display it in another detail vf page(not using standard detail page)

Best Answer chosen by Abhishek patil 26
Abhishek patil 26Abhishek patil 26
/// this is my first vf page custom controller

public with sharing class newcustomerandagent {

    public PageReference saveagent() {
    insert a; 
    id agentid=a.Id;  //this is im storing the id of inserted record.
      PageReference pageRef = new PageReference('https://c.cs15.visual.force.com/apex/agent_dtail?id='+agentid); // here im passing id through url
    return pageRef;
    
    }
}

///// this is my second vf page code
<apex:page >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:detail subject="{!$CurrentPage.parameters.id}"/>// here im getting the id which i passed from url
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

All Answers

Mukesh_SfdcDevMukesh_SfdcDev
Hi Abhishek,

Please post your code as well.

Thanks
Mukesh 
Abhishek patil 26Abhishek patil 26
Thank you i got the answer.
 
Abhishek patil 26Abhishek patil 26
/// this is my first vf page custom controller

public with sharing class newcustomerandagent {

    public PageReference saveagent() {
    insert a; 
    id agentid=a.Id;  //this is im storing the id of inserted record.
      PageReference pageRef = new PageReference('https://c.cs15.visual.force.com/apex/agent_dtail?id='+agentid); // here im passing id through url
    return pageRef;
    
    }
}

///// this is my second vf page code
<apex:page >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:detail subject="{!$CurrentPage.parameters.id}"/>// here im getting the id which i passed from url
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
This was selected as the best answer