-
How to pass Lookup field input value from VF page to controller to be passed to another page in Salesforce?
I have a requirement to use contact to create a new case. I have created a new page using case.contactID input field. On pressing a command button, the contact selected should be passed to new VF page so that that can be used to create a New case. But I am currently stuck passing the selected value even to the controller(Null is passed). I am new to VF and Apex. Please advise how to do it, then I will need to pass the value to anther page. Below are my Apex class And VF code.
VF Page Code:
--> -->
</apex:pageBlockSection>
<apex:commandButton value=" Add New Contact " action="{!callcasetabnewcon}"/>
</apex:pageBlock>
</apex:form>
Controller Code: public class Create_case { public case c {get;set;} public id conselected {get;set;} public contact con{get;set;} public string conId {get;set;}public Create_case () {
case c= new case();
}public PageReference callcasetabsearch() {
system.debug('Button method called');
Id conID= conselected;
contact con= new contact();
if(conID!= null) {
con=[Select firstname from contact where id=:conID];
}
system.debug('value of contact id is:'+ conID);
//if(c.ContactId != null) {//con=[Select firstname from contact where id=:c.ContactId];
//strText= con.firstname;
//pageReference pr = Page.assign_1_Case_search;
// pr.getParameters().put('str', strText);
//pr.getParameters().put('msg','success');
//pr.setRedirect(false);
//return pr;
//}
//else
return null;}
Log In to reply.
Popular Salesforce Blogs
Common Mistakes while Performing Salesforce Integration: What not to do
Integration means combining two different systems, portals, applications, etc with each other in order to make them as one application. Integration is very widely implemented…
Introduction of Leaflet Map in Salesforce Lightning Component
The Leaflet is an open-source JavaScript library that is used for mobile-friendly interactive maps. It has all the mapping features. It works very well across…
Salesforce Quickstart: How to Implement Salesforce Quickly and Maximize your Productivity
Salesforce is a leading Customer Relationship Management (CRM) software used globally by businesses of all sizes in terms of market share. However, Salesforce implementation can be overwhelming,…
Popular Salesforce Videos
Data Loader Alternative | Export and Import Data Using Salesforce Inspector
Find out how to export and import data using Salesforce Inspector, a very useful alternative to traditional data loader. watch this video and learn all…
Heroku | Salesforce Development Course
Knowledge of Heroku is also required to crack the Salesforce PD 1 Certification Examination. Let’s understand what Heroku is and what are its uses, in…
Migrating from Salesforce NPSP to Nonprofit Cloud
The Salesforce Nonprofit Success Pack (NPSP) is a longstanding managed package with a user-friendly constituent management application and fundraising tool. However, Salesforce is pivoting nonprofit…
Popular Salesforce Infographics
State of Appexchange Salesforce Apps Market 2025
The Salesforce AppExchange continues to expand, providing businesses with innovative tools to enhance their Salesforce experience. With thousands of solutions available, the marketplace has become…
Boost Efficiency with Salesforce Workflow Automation
Is your sales team bogged down by busywork? Let workflow automation be your hero!Give your team the gift of time!
Salesforce Training Simplified
Salesforce training simplified. Create a proven Salesforce Training model that will derive your end-users and impress your executive team. Prepare, deploy, maintain. Go through this…