-
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
Control Salesforce Lightning Tabs With Next & Back Buttons
Hello, In this post, we are going to create a sample lightning component to control <lightning:tab> with Next and Back buttons. In this code we…
Salesforce Experience Cloud – Possibilities, Cost, and Facts
Thinking about building a portal for your own customers or dealers? Here’s the inside scoop on some important facts you should understand and know about…
Enhancing Salesforce Development with SFDX: Key Strategies and Techniques
In the landscape of Salesforce development, Salesforce DX (SFDX) is a game-changer. More than just a tool, SFDX revolutionizes how developers create, test, and deploy…
Popular Salesforce Videos
Salesforce Development and Career Opportunities
Salesforce is the world’s #1 customer relationship management (CRM) platform. Salesforce allows sales reps to see everything about a customer in one place and provide…
Salesforce Winter '23 Release Highlights - Video
Cosy up by the fireplace with a nice blanket and a cup of hot cocoa; Salesforce's Winter '23 update is as cool as ice! With…
Get Rich Insights on Your Salesforce Users With Tableau | Did You Know
Did you know you can use Tableau to get rich insights on your Salesforce users? Login history, geo, browser, OS, and more are all at…
Popular Salesforce Infographics
5 Security Habits That Help Your Salesforce Admin Career
As Salesforce Admins, you drive results and deliver business value every day. You automate processes and make them more efficient. You can also learn more…
Salesforce Agentforce - The AI assistant for business growth
This infographic highlights Salesforce Agentforce, an AI-powered assistant designed to enhance business growth through automation, insights, and intelligent task management. It explains how Agentforce transforms…
Top 5 Salesforce apps for sales and marketing managers
The sales rep, marketing professionals can effectively manage on the customer inquiries from different geographical areas through Salesforce CRM. Here I’m offering a roundup of…