-
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
![Apex In Salesforce](https://images.forcetalks.com/wp-content/uploads/2022/11/05183927/Apex-In-Salesforce-1.jpg)
Best Practices of Apex In Salesforce - Here's the Complete Guide
Please follow these Salesforce Best Practices to improve our code Quality, Readability, and Reusability. Also, you can use Salesforce Best Practices to optimize our code.…
![](https://images.forcetalks.com/wp-content/uploads/2021/10/26090801/sa_1635238695DemandBlue%20Blog01.jpg)
Nine Common Pain Points Solved by Salesforce Revenue Cloud
Revenue, and especially revenue that is trending upwards, is a clear indicator of an organization’s health and potential. However, responding to fluid market shifts and…
![Data Classification](https://images.forcetalks.com/wp-content/uploads/2022/03/25104448/Data-Classification.jpg)
4 Benefits to Using Data Classification in Salesforce
Your Salesforce Org stores a ton of sensitive information; keeping things compliant and private — while still maintaining the pace of change — requires resources…
Popular Salesforce Videos
Salesforce Platform Quick Tip: How to Optimize UI for Mobile Users
How do you design Salesforce for use on either a desktop monitor or a phone? What looks great on a big monitor looks crowded on…
How to Get Jobs or Work Outside India? | Salesforce Developer vs Cloud Professional
In this Video Shrey covered answers to the three questions which are: 1. How do you find a job in Salesforce as a fresher or…
How to Nurture Leads in Salesforce Account Engagement? | Forms
Discover how Salesforce Account Engagement (also known as Pardot) helps you create and embed personalized forms, enhancing the lead nurturing experience. To show its capabilities,…
Popular Salesforce Infographics
![salesforce data loading](https://images.forcetalks.com/wp-content/uploads/2018/01/20142127/salesforce-data-loading.png)
Back to Basics: Salesforce Data Loading
Discover best practices for Salesforce data loading straight from the dataloader.io community with this useful Salesforce infographic. Users can quickly and easily delete or move…
![Salesforce Pardot Implementation](https://images.forcetalks.com/wp-content/uploads/2021/06/07202244/Salesforce-Pardot-Implementation.jpg)
Benefits of Salesforce Pardot Implementation
Cyntexa offers the best Salesforce Pardot Implementation services so that you can offer the best customer services. Our certified experts will provide Salesforce Pardot Implementation…
![App Development](https://images.forcetalks.com/wp-content/uploads/2022/05/27103513/App-Development.jpg)
How Low-Code App Development Enables Business Agility in Times of Change | Salesforce
Businesses in today's fast-changing, the digital-first world must adapt to change and meet customer demands in innovative ways. They have to quickly digitize to make…