Activity Forums Salesforce® Discussions How can I get input from user and perform the task based on that in Salesforce?

  • Avnish Yadav

    Member
    July 18, 2018 at 10:19 am

    Hello Anurag,

    Yes, you can perform the task-based on input. Let me describe you-

    1.  Use a Visualforce Page to take input.
    2.  Pass that input to apex class.
    3.  Perform the task based on input in apex class.

    Thanks.

  • Parul

    Member
    September 18, 2018 at 7:20 am

    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 5 years, 7 months ago by  Parul.
  • shariq

    Member
    September 21, 2018 at 12:41 am

    Hi,

    Just take variable getter setter and use this on page, perform task as per your logic.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos