• SFDH
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 7
    Replies

hi .. How to create 2 lookup fields in Visualforce page

  • 1st lookup field for Account
  • 2nd Looup field for contact

 

First i will select the acoount from the 1st lookup and then when i select the 2nd lookup field it should display the Contacts associated with the account i have selected from the first lookup ...

 

 

Help ....

  • September 16, 2013
  • Like
  • 0

hi ..

 

 How to create 2 lookup fields in Visualforce page

  • 1st lookup field for Account
  • 2nd Looup field for contact

first i will select the acoount from the 1st lookup and then when i sselect the 2nd lookup field it should display the Contacts associated with the account i have selected from the first lookup ...

 

Help ....

 

 

  • September 16, 2013
  • Like
  • 0

hi...

 

 I want to Create a Custom Lookup field for Account and fo Contact ,

  • After Selecting Account from 1st lookup field ,
  • when i click the 2nd lookup field for Selecting Contact it should display those contacts only related to the Account Selected .
  • if No account is being selected it should display all the Contacts ..

how to write Visualforce and controller for this ?

 

please help ..

 

email - sfdh1026@gmail.com

skype - sfdh1026

  • September 12, 2013
  • Like
  • 0

hi ...

 

 I was trying to create a custom Vf lead conversion page , in which i want to have a contact section which is to display a Existing contact bydefault and upon user's selection of clicking a button i want to display some input fields to create NEW contact , i have created the VF but the Contact section is not working as expected ... i tried checkbox method also but same result , when i use this contact pageblocksection in seperate VF page it works but not working with that Lead conversion page ... I am stuck with something and dont know what to do ... please help ......

 

  • If the existing contact selected it should use that contact for that lead ( this works for me )
  • if User wants to create a new Contact then while converthing it should create a new contact ..

 

My VF code : 

 

<apex:page standardController="lead" tabStyle="Lead" extensions="leadconvertController" >
<apex:messages />
<apex:sectionHeader title="Convert Lead"/>

 

<apex:form >
<apex:pageBlock mode="Edit">
<apex:pagemessages />
<apex:pageBlockSection title="Convert Lead" columns="1">

<apex:pageBlockSectionItem >
<apex:outputLabel value=" Record Owner" for="Record Owner"/>
<apex:inputField value="{!Lead.OwnerID}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:OutputLabel for="Send Email to the Owner">Send Email to the Owner:</apex:OutputLabel>
<apex:inputCheckbox onclick="{!Lead.Ownerid}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Last Name">Last Name</apex:outputLabel>
<apex:inputField id="Name" value="{!Lead.LastName}" />
</apex:pageBlockSectionItem>

 

<apex:pageBlockSectionItem >
<apex:outputLabel for="Account Name">Account Name</apex:outputLabel>
<apex:inputField required="true" id="Owner" value="{!Lead.Company}" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Oppt Name">Opportunity Name:</apex:outputLabel>
<apex:inputField required="true" id="Owner" value="{!Lead.Company}" />
</apex:pageBlockSectionItem>

<apex:pageblockSectionItem >
<apex:outputLabel for="no oppty">Do not create new opportunity upon conversion</apex:outputLabel>
<apex:inputCheckbox required="true" onselect="{!lead.Company}"/>
</apex:pageblockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="ConStatus">Converted Status:</apex:outputLabel>
<apex:inputField id="ConStatus" value="{!Lead.Status}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>


<apex:pageBlockSection title="Contact Information" rendered="{!!hideShow}">
Do you want to Create New Contact—<br/>
<apex:commandButton action="{!showSection1}" value="Yes" styleClass="btn" rerender="details"></apex:commandButton>

</apex:pageBlockSection>

 


<apex:pageBlockSection >

<apex:pageBlockSectionItem id="pbsi" >
<apex:outputLabel value="Existing contact Name" for="contactName"/>
<apex:selectList id="contactname" value="{!contactName}" size="1" multiselect="false">
<apex:selectoptions value="{!ContactList}" />
</apex:selectList>
</apex:pageBlockSectionItem>

</apex:pageBlockSection>

 

<apex:pageBlockSection id="newData" title="Discount Rates" rendered="{!hideshow}">

<apex:pageBlockSectionItem id="pbsi1">
<apex:outputLabel value="First Name" for="Firstname" />
<apex:inputText id="Firstname" value="{!FirstName}" size="40"/>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem id="pbsi2" >
<apex:outputLabel value="Last Name" for="Lastname"/>
<apex:inputText id="Lastname" value="{!LastName}" size="40"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Phone" for="Phone"/>
<apex:inputText value="{!Phone}" id="Phone"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Mobile" for="MobilePhone" />
<apex:inputText value="{!Mobile}" id="MobilePhone"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Title" for="Title"/>
<apex:inputText value="{!Title}" id="Title"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Email" for="Email"/>
<apex:inputText value="{!Email}" id="Email"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Website" for="Website"/>
<apex:inputText value="{!Website}" id="Website"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSection >
<apex:inputField value="{!lwn.ReportsToId}"/>
<apex:outputLabel />
</apex:pageBlockSection>

</apex:pageBlockSection>

 


<apex:pageBlockSection title="Additional Information" columns="2" id="AdditionalInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="NoofEmp">No. Of Employees:</apex:outputLabel>
<apex:inputField Id="Owner" Value="{!Lead.NumberOfEmployees}" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Revenue">Annual Revenue:</apex:outputLabel>
<apex:inputField Id="Revenue" Value="{!Lead.AnnualRevenue}" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Industry">Industry:</apex:outputLabel>
<apex:inputField Id="Industry" Value="{!Lead.Industry}" />
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Description">Description:</apex:outputLabel>
<apex:inputField Id="Description" Value="{!Lead.Description}" />
</apex:pageBlockSectionItem>

<apex:pageblockSectionItem >
<apex:outputLabel for="Phone">Phone</apex:outputLabel>
<apex:inputField required="true" id="Phone" value="{!Lead.Phone}"/>
</apex:pageblockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Email">Email</apex:outputLabel>
<apex:inputField required="true" id="Email" value="{!Lead.Email}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Website">Website:</apex:outputLabel>
<apex:inputField Id="Website" Value="{!Lead.Website}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockSection title="Task Information" columns="2" id="TaskInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Status">Status</apex:outputLabel>
<apex:inputField value="{!Task.Status}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="DueDate">Due Date</apex:outputLabel>
<apex:inputField value="{!Task.ActivityDate}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Priority">Priority</apex:outputLabel>
<apex:inputField value="{!Task.Priority}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockSection title="Description Information" columns="1" id="DescriptionInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Subject">Subject</apex:outputLabel>
<apex:inputField required="true" value="{!Task.Subject}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel for="Comments">Comments</apex:outputLabel>
<apex:inputField value="{!Task.Description}"/>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:OutputLabel for="Send Notification Email">Send Notification Email</apex:OutputLabel>
<apex:inputCheckbox onclick=""/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockSection title="Reminder" columns="1" id="Reminder">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Reminder">Reminder</apex:outputLabel>
<apex:inputField id="Reminder" value="{!task.ReminderDateTime}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockButtons >
<apex:commandButton action="{!convertLead}" value="Convert"/>
<apex:commandButton Action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

My CLASS:

public class leadconvertController
{

Opportunity opty;
Id optt;
Account account;
Contact contact;
Boolean testval = false;
public Boolean isChecked { get; set; }
public String contactName{get;set;}
private final Lead Lead;
public String leadName{get;set;}
public String FirstName {get; set;}
public String LastName {get; set;}
public contact lwn {get; set;}
public String Description{get;set;}
public String leadSource{get;set;}
public String leadIndustryName{get;set;}
public String leadstatus{get;set;}
public string Mobile{get;set;}
public string Phone{get;set;}
public string email{get;set;}
public string Website{get;set;}
public string leadrating{get;set;}
public string Title{get;set;}
Public String Street{get;Set;}
Public String City{get;Set;}
Public String State{get;Set;}
Public String PostalCode{get;Set;}
Public String Country{get;Set;}

public List<SelectOption> getContactList()

{
Contact[] Contacts = [SELECT Id,Firstname,Lastname,name,reportstoid FROM Contact];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (Contact acc : Contacts)
{
options.add(new SelectOption(acc.Name,acc.Name));
}
return options;
}

public Task getTask()
{
Task tsk = new Task();
return tsk;
}

public List<SelectOption> getStatus()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Lead.fields.status;

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public List<SelectOption> getLeadIndustryNames()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Lead.fields.Industry;

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public List<SelectOption> getPriority()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Account.fields.CustomerPriority__c;

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public leadconvertController(ApexPages.StandardController stdController)
{
this.Lead = (Lead)stdController.getRecord();
}



public PageReference convertlead()
{
try
{
String id = ApexPages.currentpage().getParameters().get('id');
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);
if(lcr.isSuccess())
{
String cId = lcr.getContactId();
Contact con = [select LastName, FirstName from Contact where Id = :cId];
String[] nameProxy = contactName.split(' ');
if(nameProxy.size() == 1)
{
con.LastName = nameProxy[0];
}
else
{
con.FirstName = nameProxy[0];
con.LastName = nameProxy[1];
}
update con;
PageReference redirect = new PageReference('/' + cId);
redirect.setRedirect(true);
return redirect;
}
}
catch(Exception e)
{
ApexPages.addMessages(e);
}
return null;
}

public pagereference showSection1()
{
setHideshow(true);
return null;
}


public Boolean getHideshow()
{
return this.testval;
}
public void setHideshow(boolean s)
{
this.testval = s;
}
}

 

please suggest me a solution :

 

mail id : sfdc1026@gmail.com

Skype : SFDC1026

 

 

 

  • September 03, 2013
  • Like
  • 0

hi ..

 

 I have Build a Vf page for Lead Convertion , but stuck with Controller please help me to finish this to convert the lead as the builtin Lead Convert Process but it should also create contact with it ... Cheak my Vf Code below

 

Please Correct the Visualforce page also , if any mistakes are there .....

 

My VF :

 

<apex:page standardController="lead" tabStyle="Lead" extensions="leadconvertController" >
<apex:messages />
<apex:sectionHeader title="Convert Lead"/>

<apex:form id="frm1">
<apex:pageBlock mode="edit" id="pgBlock">

<apex:pageBlockSection title="Contacts" columns="1" id="pgBlockSection">
<apex:pageBlockSectionItem id="pgBlockSectionitem">
<apex:outputText value="Create contacts now ?" />
<apex:selectRadio id="idRadio1" onclick="boolFunction(this);" >
<apex:selectOption itemValue="true" itemLabel="Yes" />
<apex:selectOption itemValue="false" itemLabel="No" />
</apex:selectRadio>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>

<span id="idSpan" style = "display:none">
<apex:pageBlock >
<apex:pageBlockSection title="Details" columns="1" id="Details">
<apex:outputLabel > <apex:pageBlock id="trainersBlock">
<apex:outputText value="Select for New ? " />
<apex:inputCheckbox id="isEmp" value="{!isChecked}" >
<apex:actionsupport event="onclick" rerender="SampleView" />
</apex:inputCheckbox>
<br></br>
<apex:outputPanel id="SampleView"><br></br>
<apex:pageBlockSection rendered="{!isChecked}">

<apex:pageBlockSectionItem id="pbsi1">
<apex:outputLabel value="First Name" for="Firstname" />
<apex:inputText id="Firstname" value="{!FirstName}" size="40"/>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem id="pbsi2" >
<apex:outputLabel value="Last Name" for="Lastname"/>
<apex:inputText id="Lastname" value="{!LastName}" size="40"/>
</apex:pageBlockSectionItem>

 

<apex:pageBlockSectionItem >
<apex:outputLabel value="Phone" for="Phone"/>
<apex:inputText value="{!Phone}" id="Phone"></apex:inputText>
</apex:pageBlockSectionItem>



<apex:pageBlockSectionItem >
<apex:outputLabel value="Mobile" for="MobilePhone" />
<apex:inputText value="{!Mobile}" id="MobilePhone"></apex:inputText>
</apex:pageBlockSectionItem>


<apex:pageBlockSectionItem >
<apex:outputLabel value="Title" for="Title"/>
<apex:inputText value="{!Title}" id="Title"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Email" for="Email"/>
<apex:inputText value="{!Email}" id="Email"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem >
<apex:outputLabel value="Website" for="Website"/>
<apex:inputText value="{!Website}" id="Website"></apex:inputText>
</apex:pageBlockSectionItem>

<apex:pageBlockSection >
<apex:inputField value="{!lwn.ReportsToId}"/>
<apex:outputLabel />
</apex:pageBlockSection>

</apex:pageBlockSection>
<br></br>
<apex:pageBlockSection rendered="{!IF(isChecked = true , false , true)}">


<apex:pageBlockSectionItem id="pbsi" >
<apex:outputLabel value="Existing contact Name" for="contactName"/>
<apex:selectList id="contactname" value="{!contactName}" size="1" multiselect="false">
<apex:selectoptions value="{!ContactList}" />
</apex:selectList>
</apex:pageBlockSectionItem>



</apex:pageBlockSection>
</apex:outputPanel>

</apex:pageBlock> </apex:outputLabel>
</apex:pageBlockSection>
</apex:pageBlock>
</span>

</apex:form>

<script>

function boolFunction(variable)
{
var bool = variable.value;
if(bool == 'true')
{
document.getElementById('idSpan').style.display = 'block';
}
else
document.getElementById('idSpan').style.display = 'none';
}
</script>

<apex:form >
<apex:pageBlock mode="Edit">
<apex:pagemessages />

<apex:pageBlockSection title="Convert Lead" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value=" Record Owner" for="Record Owner"/>
<apex:inputField value="{!Lead.OwnerID}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:OutputLabel for="Send Email to the Owner">Send Email to the Owner:</apex:OutputLabel>
<apex:inputCheckbox onclick="{!Lead.Ownerid}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Last Name">Last Name</apex:outputLabel>
<apex:inputField id="Name" value="{!Lead.LastName}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Account Name">Account Name</apex:outputLabel>
<apex:inputField required="true" id="Owner" value="{!Lead.Company}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Oppt Name">Opportunity Name:</apex:outputLabel>
<apex:inputField required="true" id="Owner" value="{!Lead.Company}" />
</apex:pageBlockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel for="no oppty">Do not create new opportunity upon conversion</apex:outputLabel>
<apex:inputCheckbox required="true" onselect="{!lead.Company}"/>
</apex:pageblockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="ConStatus">Converted Status:</apex:outputLabel>
<apex:inputField id="ConStatus" value="{!Lead.Status}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>






<apex:pageBlockSection title="Address Information" columns="1" id="AddressInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="StreetAdd">Street Address:</apex:outputLabel>
<apex:inputField required="true" Id="StreetAdd" Value="{!Lead.Street}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="City">City:</apex:outputLabel>
<apex:inputField required="true" Id="City" Value="{!Lead.City}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="State">State:</apex:outputLabel>
<apex:inputField required="true" Id="State" Value="{!Lead.State}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Zip">Postal Code:</apex:outputLabel>
<apex:inputField required="true" Id="Zip" Value="{!Lead.PostalCode}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information" columns="2" id="AdditionalInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="NoofEmp">No. Of Employees:</apex:outputLabel>
<apex:inputField Id="Owner" Value="{!Lead.NumberOfEmployees}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Revenue">Annual Revenue:</apex:outputLabel>
<apex:inputField Id="Revenue" Value="{!Lead.AnnualRevenue}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Industry">Industry:</apex:outputLabel>
<apex:inputField Id="Industry" Value="{!Lead.Industry}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Description">Description:</apex:outputLabel>
<apex:inputField Id="Description" Value="{!Lead.Description}" />
</apex:pageBlockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel for="Phone">Phone</apex:outputLabel>
<apex:inputField required="true" id="Phone" value="{!Lead.Phone}"/>
</apex:pageblockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Email">Email</apex:outputLabel>
<apex:inputField required="true" id="Email" value="{!Lead.Email}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Website">Website:</apex:outputLabel>
<apex:inputField Id="Website" Value="{!Lead.Website}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Task Information" columns="2" id="TaskInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Status">Status</apex:outputLabel>
<apex:inputField value="{!Task.Status}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="DueDate">Due Date</apex:outputLabel>
<apex:inputField value="{!Task.ActivityDate}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Priority">Priority</apex:outputLabel>
<apex:inputField value="{!Task.Priority}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" columns="1" id="DescriptionInformation">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Subject">Subject</apex:outputLabel>
<apex:inputField required="true" value="{!Task.Subject}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel for="Comments">Comments</apex:outputLabel>
<apex:inputField value="{!Task.Description}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:OutputLabel for="Send Notification Email">Send Notification Email</apex:OutputLabel>
<apex:inputCheckbox onclick=""/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Reminder" columns="1" id="Reminder">
<apex:pageBlockSectionItem >
<apex:outputLabel for="Reminder">Reminder</apex:outputLabel>
<apex:inputField id="Reminder" value="{!task.ReminderDateTime}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Convert"/>
<apex:commandButton Action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

Controller :

 

public class leadconvertController {

 

Lead lead;
Opportunity opty;
Id optt;
Account account;
Contact contact;

public Boolean isChecked { get; set; }

public String contactName{get;set;}

public String leadName{get;set;}
public String FirstName {get; set;}
public String LastName {get; set;}
public contact lwn {get; set;}
public String Description{get;set;}

public String leadSource{get;set;}
public String leadIndustryName{get;set;}
public String leadstatus{get;set;}
public string Mobile{get;set;}
public string Phone{get;set;}
public string email{get;set;}
public string Website{get;set;}
public string leadrating{get;set;}
public string Title{get;set;}
Public String Street{get;Set;}
Public String City{get;Set;}
Public String State{get;Set;}
Public String PostalCode{get;Set;}
Public String Country{get;Set;}

public List<SelectOption> getContactList() {
Contact[] Contacts = [SELECT Id,Firstname,Lastname,name,reportstoid FROM Contact];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (Contact acc : Contacts) {
options.add(new SelectOption(acc.Name,acc.Name));
}
return options;}

public Task getTask(){
Task tsk = new Task();
return tsk;
}

public List<SelectOption> getStatus()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Lead.fields.status;
//Lead.LeadSource.getDescribe();

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public List<SelectOption> getLeadIndustryNames()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Lead.fields.Industry;
//Lead.LeadSource.getDescribe();

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public List<SelectOption> getPriority()
{
List<SelectOption> options = new List<SelectOption>();

Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Account.fields.CustomerPriority__c;
//Lead.LeadSource.getDescribe();

List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry f : ple)
{
options.add(new SelectOption(f.getLabel(), f.getValue()));
}
return options;
}

public leadconvertController(ApexPages.StandardController controller) {

}


}

 

 

please provide the code for this ....

 

 

  • August 28, 2013
  • Like
  • 0

Hi Everyone,

 

I would like to get some suggestions on how to display sections on a Visualforce page based on specific checkboxes selected.

 

here is the Question ?

 

i made a VF page in which i have to display 2 radio buttons 

  1. Existing contacts ,
  2. New contacts ,

 

if i select the first one look up field should be displayed and the existing contact would be selected ,

if the second radio button clicked New fields should be displayed for creating the Contacts ,

 

how is this possible ?  plz help

  • August 27, 2013
  • Like
  • 0

I need to Customize "Convert LEAD " page ,

  • Where i want to show existing Contacts .
  •  It should show values of both existing and new contact details like first name, last name, email, phone as radio buttons next to each other and allow them to select one of them before converting.

Is it possible without Visualforce page , if YES please provide the details

 

 

else

 

if NO then please provide Code , any help will be thankfull .... 

 

thanks in advance 

  • August 16, 2013
  • Like
  • 0

I am new to coding, so please bear with me .....

 

my Visualforce code has two parts the first half is success and in my Second part i have to use JAVASCRIPT to get the Total Price by Multiplying two values from two Different fields 

 

for eg : by calculating the price(5)*Qty(5) =Total(25)  should be displayed , i messed up somewhere and don’t know wt to do next ....

 

 

Please Help and suggest me ...... 

 

My VF code as follows:

 

<apex:page Controller="opty2proposal" id="page" >

<script type="text/javascript">

function updateRate()
{


var rat=document.getElementById('{!$Component.frm.pb.pbs.pbt.pbsi.rate}');
alert("Rate:"+rat);
var discP= document.getElementById('{!$Component.frm.pb.pbt.col1.pbs1.pbsi1.discPcrnt}'); 

alert("Total:"+rat*discP);
document.getElementByID("discRate").value = rat*discP;

}
</script> 

<apex:form id="Header" >
<form name="PrintInformationTop">
<center>
<input type="button" name="PrintInformationTop" value=" Print" onClick = "window.print()" />
</center>
</form>

<apex:sectionHeader title="Multiple Records"/>
<apex:pageBlock title="Proposal header">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />

</apex:pageBlockButtons>

<apex:pageBlockSection >

<apex:pageBlockSectionItem id="Opportunity"> 
<apex:outputLabel value="Opportunity Name" for="OpportunityName" />
<apex:inputText id="OpportunityName" value="{!opty.name}" size="40"/> 
</apex:pageBlockSectionItem>



<apex:pageBlockSectionItem id="Account"> 
<apex:outputLabel value="Account Name" for="AccountName" />
<apex:inputText id="AccountName" value="{!account.name}" size="40"/> 
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem id="Contact" >
<apex:outputLabel value="Contact Name" for="ContactName"/> 
<apex:selectList id="leadName" value="{!contactName}" size="1" multiselect="false">
<apex:selectoptions value="{!ContactList}" />
</apex:selectList>
</apex:pageBlockSectionItem>

 

<apex:pageBlockSectionItem >
<apex:outputLabel value="TextArea" for="TextArea"/>
<apex:inputTextarea id="TextArea" value="{!Description}"/>
</apex:pageBlockSectionItem> 

</apex:pageBlockSection>
</apex:pageBlock> 
</apex:form>



<apex:form id="frm">
<apex:sectionHeader title="Proposal Line Code" subtitle="AddProduct" />

<apex:pageBlock title="AddrowDynamically" id="pb" >

<apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save_line}" />
</apex:pageBlockButtons>

 

<apex:pageBlockSection id="pbs" >
<apex:variable value="{!0}" var="rowNumber" />


<apex:commandButton value="Add" action="{!addNewObject}" reRender="newItems,panelWithVar,pbs" immediate="true"/>


<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber" />
</apex:outputPanel>

 

<apex:pageBlockTable value="{!objectsToInsert}" var="item" id="pbt">
<apex:column width="5%">

<apex:commandButton action="{!removeNewObject}" value=" X " reRender="newItems,panelWithVar,pbs">
<apex:param name="p1" value="{!rowNumber}" assignTo="{!numberOfRowToRemove}"/>
</apex:commandButton>

</apex:column>



<apex:column >
<apex:outputLabel value="Product Name" for="ProName"/>

<apex:selectList id="ProName" value="{!productName}" size="1" multiselect="false">
<apex:selectoptions value="{!ProductList}" />
</apex:selectList>

</apex:column>

<apex:column headerValue="Proposal Line Name">

<apex:inputField value="{!item.Name}"/>

</apex:column>

<apex:column headerValue="Price">

<apex:pageBlockSectionItem id="pbsi" >
<apex:inputField id="rate" value="{!item.Price__c}" />
</apex:pageBlockSectionItem>


</apex:column>

<apex:column headerValue="Quantity" id="col1" >

<apex:pageBlockSectionItem id="pbsi1">
<apex:inputField id="discPcrnt" value="{!item.Quantity__c}" onchange="updateRate();"/>
</apex:pageBlockSectionItem>

</apex:column>



<apex:column headerValue="Total" >

<apex:pageBlockSectionItem >
<apex:outputText id="discRate" rendered="{!check}"/>
</apex:pageBlockSectionItem>
</apex:column>


<apex:column headerValue="Description">
<apex:inputField value="{!item.Description__c}"/>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

 

 

 

and my Controller :

 

public class opty2proposal{

public String getIsEditable() {
return null;
}


public Boolean check{ get; set; }



public List<Proposal_Line__c> objectsToInsert { get; set; }
public Integer numberOfRowToRemove { get; set; }

public String ProductName{get;set;}
public string test{get;set;}

Opportunity opty;
Account account;
Contact contact;


public String ContactName{get;set;}
public string Description{get;set;}
public Integer Quantity{get;set;}
public Integer price{get;set;}
public Integer total{get;set;}




public opty2proposal() {

objectsToInsert = new List<Proposal_Line__c>();
objectsToInsert.add(new Proposal_Line__c());


opty = [select id, name, accountId, OwnerId, Description from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];


}
public PageReference addNewObject(){

Proposal_Line__c newObject = new Proposal_Line__c();
objectsToInsert.add(newObject);

return null;
}

public PageReference removeNewObject(){

objectsToInsert.remove(numberOfRowToRemove);

return null;
}
public List<SelectOption> getProductList() {
Product2[] products = [SELECT Id,name FROM product2 LIMIT 10 ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (product2 acc : products) {
options.add(new SelectOption(acc.Name,acc.Name));
}
return options;}


public PageReference save_close()
{

Proposal_Line__c objectsToInsert=new Proposal_Line__c(
name=ProductName);
insert objectsToInsert;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}


public Opportunity getOpty() {
return opty;
}

 


public Account getAccount(){
account=[select id, name,OwnerId from Account where id=:opty.accountId];
return account;
}

public List<SelectOption> getContactList() {
Contact[] Contacts = [SELECT Id,Firstname,Lastname,name FROM Contact Where Accountid = :opty.accountId ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (Contact con : Contacts) {
options.add(new SelectOption(con.Name,con.Name));
}
return options;
}

public void save() {


Proposal_Header__c ph=new Proposal_Header__c(
Name=contactName,
Account_Name__c=Account.name,
Opportunity_Name__c=opty.name,
Text_Area__c=Description
//CodeTotal__c
);
insert ph;
}
public PageReference save_line() {

insert objectsToInsert;
PageReference pg=New PageReference('/006/o');
return pg;

}

}

 

  • July 19, 2013
  • Like
  • 0

hi ..

 

 How to create 2 lookup fields in Visualforce page

  • 1st lookup field for Account
  • 2nd Looup field for contact

first i will select the acoount from the 1st lookup and then when i sselect the 2nd lookup field it should display the Contacts associated with the account i have selected from the first lookup ...

 

Help ....

 

 

  • September 16, 2013
  • Like
  • 0

hi...

 

 I want to Create a Custom Lookup field for Account and fo Contact ,

  • After Selecting Account from 1st lookup field ,
  • when i click the 2nd lookup field for Selecting Contact it should display those contacts only related to the Account Selected .
  • if No account is being selected it should display all the Contacts ..

how to write Visualforce and controller for this ?

 

please help ..

 

email - sfdh1026@gmail.com

skype - sfdh1026

  • September 12, 2013
  • Like
  • 0

I need to Customize "Convert LEAD " page ,

  • Where i want to show existing Contacts .
  •  It should show values of both existing and new contact details like first name, last name, email, phone as radio buttons next to each other and allow them to select one of them before converting.

Is it possible without Visualforce page , if YES please provide the details

 

 

else

 

if NO then please provide Code , any help will be thankfull .... 

 

thanks in advance 

  • August 16, 2013
  • Like
  • 0

I am new to coding, so please bear with me .....

 

my Visualforce code has two parts the first half is success and in my Second part i have to use JAVASCRIPT to get the Total Price by Multiplying two values from two Different fields 

 

for eg : by calculating the price(5)*Qty(5) =Total(25)  should be displayed , i messed up somewhere and don’t know wt to do next ....

 

 

Please Help and suggest me ...... 

 

My VF code as follows:

 

<apex:page Controller="opty2proposal" id="page" >

<script type="text/javascript">

function updateRate()
{


var rat=document.getElementById('{!$Component.frm.pb.pbs.pbt.pbsi.rate}');
alert("Rate:"+rat);
var discP= document.getElementById('{!$Component.frm.pb.pbt.col1.pbs1.pbsi1.discPcrnt}'); 

alert("Total:"+rat*discP);
document.getElementByID("discRate").value = rat*discP;

}
</script> 

<apex:form id="Header" >
<form name="PrintInformationTop">
<center>
<input type="button" name="PrintInformationTop" value=" Print" onClick = "window.print()" />
</center>
</form>

<apex:sectionHeader title="Multiple Records"/>
<apex:pageBlock title="Proposal header">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}" />

</apex:pageBlockButtons>

<apex:pageBlockSection >

<apex:pageBlockSectionItem id="Opportunity"> 
<apex:outputLabel value="Opportunity Name" for="OpportunityName" />
<apex:inputText id="OpportunityName" value="{!opty.name}" size="40"/> 
</apex:pageBlockSectionItem>



<apex:pageBlockSectionItem id="Account"> 
<apex:outputLabel value="Account Name" for="AccountName" />
<apex:inputText id="AccountName" value="{!account.name}" size="40"/> 
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem id="Contact" >
<apex:outputLabel value="Contact Name" for="ContactName"/> 
<apex:selectList id="leadName" value="{!contactName}" size="1" multiselect="false">
<apex:selectoptions value="{!ContactList}" />
</apex:selectList>
</apex:pageBlockSectionItem>

 

<apex:pageBlockSectionItem >
<apex:outputLabel value="TextArea" for="TextArea"/>
<apex:inputTextarea id="TextArea" value="{!Description}"/>
</apex:pageBlockSectionItem> 

</apex:pageBlockSection>
</apex:pageBlock> 
</apex:form>



<apex:form id="frm">
<apex:sectionHeader title="Proposal Line Code" subtitle="AddProduct" />

<apex:pageBlock title="AddrowDynamically" id="pb" >

<apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save_line}" />
</apex:pageBlockButtons>

 

<apex:pageBlockSection id="pbs" >
<apex:variable value="{!0}" var="rowNumber" />


<apex:commandButton value="Add" action="{!addNewObject}" reRender="newItems,panelWithVar,pbs" immediate="true"/>


<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber" />
</apex:outputPanel>

 

<apex:pageBlockTable value="{!objectsToInsert}" var="item" id="pbt">
<apex:column width="5%">

<apex:commandButton action="{!removeNewObject}" value=" X " reRender="newItems,panelWithVar,pbs">
<apex:param name="p1" value="{!rowNumber}" assignTo="{!numberOfRowToRemove}"/>
</apex:commandButton>

</apex:column>



<apex:column >
<apex:outputLabel value="Product Name" for="ProName"/>

<apex:selectList id="ProName" value="{!productName}" size="1" multiselect="false">
<apex:selectoptions value="{!ProductList}" />
</apex:selectList>

</apex:column>

<apex:column headerValue="Proposal Line Name">

<apex:inputField value="{!item.Name}"/>

</apex:column>

<apex:column headerValue="Price">

<apex:pageBlockSectionItem id="pbsi" >
<apex:inputField id="rate" value="{!item.Price__c}" />
</apex:pageBlockSectionItem>


</apex:column>

<apex:column headerValue="Quantity" id="col1" >

<apex:pageBlockSectionItem id="pbsi1">
<apex:inputField id="discPcrnt" value="{!item.Quantity__c}" onchange="updateRate();"/>
</apex:pageBlockSectionItem>

</apex:column>



<apex:column headerValue="Total" >

<apex:pageBlockSectionItem >
<apex:outputText id="discRate" rendered="{!check}"/>
</apex:pageBlockSectionItem>
</apex:column>


<apex:column headerValue="Description">
<apex:inputField value="{!item.Description__c}"/>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

 

 

 

and my Controller :

 

public class opty2proposal{

public String getIsEditable() {
return null;
}


public Boolean check{ get; set; }



public List<Proposal_Line__c> objectsToInsert { get; set; }
public Integer numberOfRowToRemove { get; set; }

public String ProductName{get;set;}
public string test{get;set;}

Opportunity opty;
Account account;
Contact contact;


public String ContactName{get;set;}
public string Description{get;set;}
public Integer Quantity{get;set;}
public Integer price{get;set;}
public Integer total{get;set;}




public opty2proposal() {

objectsToInsert = new List<Proposal_Line__c>();
objectsToInsert.add(new Proposal_Line__c());


opty = [select id, name, accountId, OwnerId, Description from Opportunity where id = :ApexPages.currentPage().getParameters().get('id')];


}
public PageReference addNewObject(){

Proposal_Line__c newObject = new Proposal_Line__c();
objectsToInsert.add(newObject);

return null;
}

public PageReference removeNewObject(){

objectsToInsert.remove(numberOfRowToRemove);

return null;
}
public List<SelectOption> getProductList() {
Product2[] products = [SELECT Id,name FROM product2 LIMIT 10 ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (product2 acc : products) {
options.add(new SelectOption(acc.Name,acc.Name));
}
return options;}


public PageReference save_close()
{

Proposal_Line__c objectsToInsert=new Proposal_Line__c(
name=ProductName);
insert objectsToInsert;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}


public Opportunity getOpty() {
return opty;
}

 


public Account getAccount(){
account=[select id, name,OwnerId from Account where id=:opty.accountId];
return account;
}

public List<SelectOption> getContactList() {
Contact[] Contacts = [SELECT Id,Firstname,Lastname,name FROM Contact Where Accountid = :opty.accountId ];
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('- None Selected - ','- None Selected - '));
for (Contact con : Contacts) {
options.add(new SelectOption(con.Name,con.Name));
}
return options;
}

public void save() {


Proposal_Header__c ph=new Proposal_Header__c(
Name=contactName,
Account_Name__c=Account.name,
Opportunity_Name__c=opty.name,
Text_Area__c=Description
//CodeTotal__c
);
insert ph;
}
public PageReference save_line() {

insert objectsToInsert;
PageReference pg=New PageReference('/006/o');
return pg;

}

}

 

  • July 19, 2013
  • Like
  • 0

Hello,

 

In Apex there is the substring function.  I'm wondering, in Visualforce is there an equivalent.

E.G.  if I have a string 'testme:helloVal'.  I want to get the value of the string from the colon ";" to the end of the string.

How can do this within a Visualforce page (not in a controller).

 

I know there are functions such as "Right",  "LEN" etc that formula's use (e.g. with a workflow rule) and that some of these can be applied to visualforce, but I wasn't sure how I could make the above requirement work.

 

Any tips welcomed.

 

Thanks for your help!

Hi all,

 

On my Visualforce page, I would like to display the account names in a dropdown list.

 

For each account record, I have a custom field called display. If that display box is ticked, I would like to display the name of the account in the list. 

 

Is there a way to do that please? 

 

Many thanks 

 

  • February 14, 2010
  • Like
  • 0