• surya teja 46
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
<apex:page controller="onaccountdata">
    <apex:form id="out">
        <apex:pageBlock title="Account">
            <apex:pageBlockSection >
                <apex:inputtext label="Account Name" value="{!enteredname}"/>
                <apex:commandButton value="Click" action="{!getcontacts}" reRender="out"/>
                <apex:inputtext label="Industry" value="{!industry}"/>
            </apex:pageBlockSection>
        </apex:pageBlock> 
        <apex:outputPanel id="e">{!error}</apex:outputPanel>
        <apex:pageBlock title="Contacts"> 
            <apex:commandButton value="save" action="{!customsave}" reRender="e"/>
            <apex:pageblockSection >
                <apex:inputtext label="First Name" value="{!firstname}"/>
                <apex:inputtext label="Last Name" value="{!lastname}"/>
                <apex:inputtext label="Phone" value="{!phone}"/>
                <apex:inputtext label="Email" value="{!email}"/>
            </apex:pageblockSection>
        </apex:pageBlock>   
    </apex:form>
</apex:page>

================================================================================================

public class onaccountdata 
{

    public onaccountdata() {

    }


    public onaccountdata(ApexPages.StandardController controller) {

    }

    public string enteredname{get; set;}
    public string industry {get; set;}
    public string firstname{get; set;}
    public string lastname{get; set;}
    public string phone{get; set;}
    public string email{get; set;}
    public exception error{get; set;}
    public contact con{get;set;}

    public void getcontacts()
    {
        account acc = [select id, name, industry from account where name =: enteredname limit 1];
        con = [select id, firstname, lastname, phone, email from contact where accountid =: acc.id limit 1];
        industry = acc.industry;
        firstname = con.firstname;
        lastname = con.lastname;
        phone = con.phone;
        email = con.email;
    }
    
    public void customsave()
    {   
        if(con.id != null && con.id != '')
        {
           con.firstname = firstname;
           con.lastname = lastname;
           con.phone = phone;
           con.email = email;
           try
           {
           update con; 
            }
            catch (exception ex)
            {
                error = ex;
              
            }
        }
        
        else
        {
            contact con = new contact();
            con.firstname = firstname;
            con.lastname = lastname;
            con.phone = phone;
            con.email = email;
            try 
            {
            insert con;
            }
            catch (exception ex)
            {
                error = ex;
            }
        }
    }
}​
hi 
i am a salesforce learner 
I am getting a problem in my code any one give me a guidence 
this is my vf code
=====================
<apex:page standardController="lead" extensions="newfunctionofleads" tabStyle="lead">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockButtons location="top">
              <apex:commandButton value="New" action="{!gotoeditpage}"/>
          </apex:pageBlockButtons>
         </apex:pageBlock>
  </apex:form>
</apex:page>

this is my controller:
==============
public with sharing class newfunctionofleads {

    public newfunctionofleads(ApexPages.StandardController controller) 
    }
    public void gotoeditpage()
    {
        list<user> lstusers = [Select id, name, profileid from user];
        
        for(user u: lstusers)
        {
          if(u.profileid == '00e280000028dLaAAI' )
         {
             getvender();
         }
         else if(u.profileid == '00e28000000Z6uZAAS')
         { 
             getadmin();
         }
        }
    } 
    public pagereference getvender()
    {
       pagereference pgref = new pagereference('https://ap2.salesforce.com/00Q/e?retURL=%2F00Q%2Fo');
       return pgref.setredirect(true);  
    }
    
    public pagereference getadmin()
    {
       pagereference pgref = new pagereference('https://ap2.salesforce.com/00Q/e?retURL=%2F00Q%2Fo');
       return pgref.setredirect(true);
    }
}
==========================================
I am created a new button when vendor user hits it, directly vendor record type should open silmilarly with the other user so please help me to over come this problem 
hi 
i am a salesforce learner 
I am getting a problem in my code any one give me a guidence 
this is my vf code
=====================
<apex:page standardController="lead" extensions="newfunctionofleads" tabStyle="lead">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockButtons location="top">
              <apex:commandButton value="New" action="{!gotoeditpage}"/>
          </apex:pageBlockButtons>
         </apex:pageBlock>
  </apex:form>
</apex:page>

this is my controller:
==============
public with sharing class newfunctionofleads {

    public newfunctionofleads(ApexPages.StandardController controller) 
    }
    public void gotoeditpage()
    {
        list<user> lstusers = [Select id, name, profileid from user];
        
        for(user u: lstusers)
        {
          if(u.profileid == '00e280000028dLaAAI' )
         {
             getvender();
         }
         else if(u.profileid == '00e28000000Z6uZAAS')
         { 
             getadmin();
         }
        }
    } 
    public pagereference getvender()
    {
       pagereference pgref = new pagereference('https://ap2.salesforce.com/00Q/e?retURL=%2F00Q%2Fo');
       return pgref.setredirect(true);  
    }
    
    public pagereference getadmin()
    {
       pagereference pgref = new pagereference('https://ap2.salesforce.com/00Q/e?retURL=%2F00Q%2Fo');
       return pgref.setredirect(true);
    }
}
==========================================
I am created a new button when vendor user hits it, directly vendor record type should open silmilarly with the other user so please help me to over come this problem