Activity › Forums › Salesforce® Discussions › How can I get input from user and perform the task based on that in Salesforce?
Tagged: Input Field, Method in Apex Class, Salesforce Apex Class, Salesforce Fields, Salesforce Methods, Salesforce Visualforce Page
-
How can I get input from user and perform the task based on that in Salesforce?
Posted by Anurag algoworks on July 17, 2018 at 12:13 PMHow can I get an input from user and perform the task based on that in Salesforce?
shariq replied 7 years, 8 months ago 4 Members · 3 Replies -
3 Replies
-
Hello Anurag,
Yes, you can perform the task-based on input. Let me describe you-
- Use a Visualforce Page to take input.
- Pass that input to apex class.
- Perform the task based on input in apex class.
Thanks.
- [adinserter block='9']
-
Yes, you can get input from user by visualforce page and perform task based on visualforce page by using apex class
Example:
Apex
public with sharing class ContactController {
public Contact c { get; set; }
public List<Contact> samepage { get; set; }
public ContactController(){
c=new Contact();
}public PageReference save() {
insert c;
samepage= [select id,FirstName,LastName,Email,Birthdate from Contact where id=:c.id];return null;
}}Visualforce Page:
<apex:page Controller=”ContactController” >
<apex:form ><apex:pageBlock title=”Edit Contact”>
<apex:pageBlockSection columns=”1″>
<apex:inputField value=”{!c.FirstName}”/>
<apex:inputField value=”{!c.LastName}”/>
<apex:inputField value=”{!c.Email}”/>
<apex:inputField value=”{!c.Birthdate}”/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action=”{!save}” value=”Save”/>
</apex:pageBlockButtons>
<apex:pageBlockTable value=”{!samepage}” var=”c”>
<apex:column headerValue=”First Name”>
<apex:outputField value=”{!c.Firstname}”/>
</apex:column><apex:column headerValue=”Last Name”>
<apex:outputField value=”{!c.Lastname}”/>
</apex:column></apex:column>
</apex:pageBlockTable>
</apex:pageBlock></apex:form>
</apex:page>thanks
-
This reply was modified 7 years, 8 months ago by
Parul.
-
This reply was modified 7 years, 8 months ago by
-
Hi,
Just take variable getter setter and use this on page, perform task as per your logic.
Hope this helps.
Log In to reply.