-
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
How To Create Custom Settings And Custom Objects | Salesforce Developer Guide
Custom Settings Custom settings are similar to custom objects which allow us to customize org data. Following are the steps to create Custom settings:- 1.…
Apex Basics and Database | Salesforce Apex Tutorial Guide
In this blog we’ll learn about Apex, Apex features, Features not supported by Apex, when to use Apex, Flows of Action, Apex Environments, and Tools…
A Dive into Most Popular Salesforce Experience Cloud Templates
Salesforce Experience Cloud offers a user-friendly solution that is becoming the go-to choice for businesses across different industries aiming to create a standout online presence.…
Popular Salesforce Videos
Salesforce Flow: How to Build a Flow Data Table
In this video, Salesforce Made Simple gives a quick run-down on constructing a data table inside the Salesforce Flow Builder. Whether they’re buying movie tickets,…
How to Download Backup Files from Salesforce Using UIPath Robots
How to download backup files from Salesforce using UiPath robots. How to get the latest file from the folder: Directory.GetFiles(“YOUR FOLDER”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).First The link…
Basics of Salesforce Flow in 15 minutes
In this video, Jitendra Zaa gives a detailed overview of the basics of Salesforce Flow in just 15 minutes. He covers everything from how to…
Popular Salesforce Infographics
How Sales Reps are Staying at the Top of Their Game | Salesforce Guide
Sales reps around the world had to rapidly adopt new methods to work around lockdowns and travel restrictions. In some cases, this meant learning new…
How to Choose the Right Salesforce Partner
Choosing the right partner is a key factor that could make or break your project’s success. Salesforce is a mighty CRM platform, and that’s why…
What Can Salesforce’ Non Profit Success Pack Provide You With?
The Nonprofit Success Pack NPSP (formerly known as "Nonprofit Starter Pack) is a set of managed packages developed and maintained by Salesforce.org and made available…