• jburnsST
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies

I have a custom list button on a related list which is displayed on a VF page,the button opens another vf page into an iframe . The page is opening fine in the iframe.

 

I am trying to pre-populate fields in the VF page:

 

 

 

Button code: (I tried it both with a ? and an & after quoteCreate)

 

window.open("/apex/quoteCreate?lead={!Lead__c.Name}",'q','height=450,width=650');

 I set the id of the input field in the vf page I am trying to populate to lead 

 

<apex:inputField id="lead" value="{!Quote__c.Lead__c}" required="false"/>

 but when I inspect the element using chrome it shows the NAME and ID as: j_id0:j_id2:j_id3:j_id12:lead

 

(which i have also tried using j_id0:j_id2:j_id3:j_id12:lead={!Lead__c.Name} this thows an error: The name 'quoteCreate&j_id0:j_id2:j_id3:j_id12:lead=L-0744' can only contain alphanumeric characters, must begin with a letter, and must be unique.)

 

So what i am trying to do is populate the field through my button code! someone please help!

 

JB

I am building a tabbed layout for an application we are building,due to the large number of related objects to keep things organized.

 

We have multiple custom buttons on our custom objects which execute apex class methods and perform javascript functions. Here is an example :

 

 

{!requireScript("/soap/ajax/13.0/connection.js")} 

try
{
var leadId = "{!Lead__c.Id}";
sforce.apex.execute("ActivityClass", "AddDisposition", {recordId:leadId, objectType:"Lead"});
window.location.reload();
}
catch(err)
{
alert("Error logging disposition: " + err.toString());
}

 How would I duplicate this button in visual force?

 

I tried includng the class as an extention in the VF page:

 

<apex:page id="tabLayout" showHeader="true" standardstylesheets="false" standardController="Lead__c" extensions="ActivityClass">

 But when I call the method:

 

<apex:commandButton value="Log Disposition"  action="{!AddDisposition}"/>

 I received: Save error: /apex/tabLayoutLead @36,79 action="#{AddDisposition}": Unknown method 'Lead__cStandardController.AddDisposition()'

 

I have included both the ActivityClass and the tabbed VF page below:

 

ActivityClass:

 

/*
	Class summary: Functionality for logging dispositions on client and lead records
	Last modified by: J. Duhaney
	Last modified on: 11/8/2011
*/
global class ActivityClass {
	
	public static Boolean AddDisposition(List<Client__c> clients)
	{
		List<Task> tasks = new List<Task>();
		
		for (Client__c client : clients)
		{
			if (client.Disposition__c != null)
			{
				Task task = new Task();
				task.OwnerId = client.LastModifiedById;
				task.Subject = client.Disposition__c;
				task.WhatId = client.Id;
				task.Description = client.Notes__c;
				
				task.Priority = 'Normal';
				task.Status = 'Completed';
				task.ActivityDate = date.today();
				tasks.add(task);
				
				client.Disposition__c = '';
				client.Notes__c = '';
			}
		}
		
		insert tasks;
		update clients;
		return true;
	} 
	
	public static Boolean AddDisposition(List<Lead__c> leads)
	{
		List<Task> tasks = new List<Task>();
		
		for (Lead__c lead : leads)
		{
			Task task = new Task();
			task.OwnerId = lead.LastModifiedById;
			task.Subject = lead.Disposition__c;
			task.WhatId = lead.Id;
			task.Description = lead.Notes__c;
			
			task.Priority = 'Normal';
			task.Status = 'Completed';
			task.ActivityDate = date.today();
			tasks.add(task);
			
			lead.Disposition__c = '';
			lead.Notes__c = '';
		}
		
		insert tasks;
		update leads;
		return true;
	} 

	webservice static Boolean AddDisposition(Id recordId, String objectType)
	{
		if (objectType == 'Client')
		{
			List<Client__c> clients = [SELECT LastModifiedById, Disposition__c, Notes__c FROM Client__c 
									WHERE Id = :recordId];
		
			return AddDisposition(clients);
		}
		else if (objectType == 'Lead')
		{
			List<Lead__c> leads = [SELECT LastModifiedById, Disposition__c, Notes__c FROM Lead__c 
									WHERE Id = :recordId];
		
			return AddDisposition(leads);
		}
		else
		{
			return false;
		}
	}
	
	// Tests the add disposition functionality
	public static testMethod void TestAddDisposition()
    {    	
    	Client__c testClient = Unit_Tests.CreateTestClient();
    	testClient.Notes__c = 'Test notes';
    	testClient.Disposition__c = 'Email Sent';
    	upsert testClient;
    	
    	AddDisposition(testClient.Id, 'Client');
    	
    	Lead__c testLead = Unit_Tests.CreateTestLead();
    	testLead.Notes__c = 'Test notes';
    	testLead.Disposition__c = 'Email Sent';
    	upsert testLead;
    	
    	AddDisposition(testLead.Id, 'Lead');
    }
}

 

 

VF Tabbed Layout:

 

<apex:page id="tabLayout" showHeader="true" standardstylesheets="false" standardController="Lead__c" extensions="ActivityClass">
     <style>
     .tabStyle
     {
     	background-color: white ;
     }
    .activeTab {background-color: #1797c0 ; color:white; background-image:none}
    .inactiveTab { background-color: lightgray; color:black; background-image:none}
    </style>
    <script type="text/javascript">
function create()

window.open("{!Lead__c.Contract_URL__c}",'name','height=450,width=650');

</script>
  	    
	<apex:sectionHeader title="Lead ({!Lead__c.Name})" subtitle="{!Lead__c.First_Name__c} {!Lead__c.Last_name__c}" />
	<apex:toolbar id="theToolbar" height="50px;" itemSeparator="none" style="background-color:#1797c0;background-image:none">
        <apex:form >
        <apex:toolbarGroup itemSeparator="none" id="toobarGroupLinks">
            
            <apex:outputLabel >Disposition</apex:outputLabel>
		<apex:inputField value="{!Lead__c.Disposition__c}" style="width: 300px; height: 25px" />
		<apex:outputLabel >Disposition Notes</apex:outputLabel>
		<apex:inputField value="{!Lead__c.Notes__c}" style="width: 300px; height: 25px" />
		
        </apex:toolbarGroup>
       </apex:form>
    </apex:toolbar>   
	
	<apex:pageBlock > 
	
	 <apex:pageBlockButtons >
      <apex:form >
      <apex:commandButton value="Create Contract"  onclick="create()" />
      <apex:commandButton value="Log Disposition" action="{!AddDisposition}"/>
      </apex:form>
      </apex:pageBlockButtons> 
     
	
		<apex:pageBlockSection title="Client Information" columns="2" collapsible="true">
		<apex:outputField value="{!Lead__c.First_Name__c}" />
		<apex:outputField value="{!Lead__c.CO_First_Name__c}" />
		
		<apex:outputField value="{!Lead__c.Last_name__c}" />
		<apex:outputField value="{!Lead__c.CO_Last_Name__c}" />
		</apex:pageBlockSection>
		
		
	<apex:pageBlockSection columns="1" collapsible="true">
    <apex:tabPanel switchType="lead__c" selectedTab="actTab" id="tabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        
		<apex:tab label="Activity" name="actTab" id="actTab">
			<apex:relatedList list="OpenActivities" />
			<apex:relatedList list="ActivityHistories" />
		</apex:tab>
		<apex:tab label="Quote" name="qTab" id="qTab">
		
		<apex:relatedList list="Quote__r" />
		<apex:iframe id="q" height="520px">
			</apex:iframe>
		</apex:tab>
		<apex:tab label="Debts" name="debtTab" id="debtTab">
			<apex:include pageName="addDebt"> </apex:include>
			<apex:relatedList list="Lead_Debt__r" />
			<apex:iframe id="ld" height="350px">
			</apex:iframe>
		</apex:tab>
		<apex:tab label="Financial Profile" name="finTab" id="finTab">
			<apex:relatedList list="Financial_Profiles__r" />
			<apex:iframe id="fp" height="1050px">
			</apex:iframe>
		</apex:tab>
        <apex:tab label="Personal Information" name="piTab" id="piTab">
	
			<apex:page standardController="Lead__c">
<apex:form >

<apex:pageBlock title="Personal Information" >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion >
<apex:pageBlockSection columns="2">
<apex:inputField value="{!Lead__c.First_Name__c}"/>
<apex:inputField value="{!Lead__c.Last_name__c}"/>
<apex:inputField value="{!Lead__c.MI__c}"/>
<apex:inputField value="{!Lead__c.Address_Line_1__c}"/>
<apex:inputField value="{!Lead__c.Address_Line_2__c}"/>
<apex:inputField value="{!Lead__c.City__c}"/>
<apex:inputField value="{!Lead__c.State__c}"/>
<apex:inputField value="{!Lead__c.Postal_Code__c}"/>
<apex:inputField value="{!Lead__c.Email_Address__c}"/>
<apex:inputField value="{!Lead__c.Best_Phone__c}"/>
<apex:inputField value="{!Lead__c.Cell_Phone__c}"/>
<apex:inputField value="{!Lead__c.Home_Phone__c}"/>
<apex:inputField value="{!Lead__c.Work_Phone__c}"/>
<apex:inputField value="{!Lead__c.MAIDEN__c}"/>
<apex:inputField value="{!Lead__c.Social_Security_Number__c}"/>
<apex:inputField value="{!Lead__c.DOB__c}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Co-Debt Information"/>
<apex:outputPanel >
<apex:inputField value="{!Lead__c.CODEBTINFO__c}">
<apex:actionSupport event="onchange" rerender="Personal Information" status="status"/>
</apex:inputField>
<apex:actionStatus startText="applying value..." id="status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageBlockSection rendered="{!Lead__c.CODEBTINFO__c == 'CO Info is the same'}">
<apex:inputField value="{!Lead__c.CO_Work_Phone__c}"/>
<apex:inputField value="{!Lead__c.CO_Cell_Phone__c}"/>


<apex:inputField value="{!Lead__c.CO_Work_Phone__c}"/>

<apex:inputField value="{!Lead__c.CO_Last_Name__c}"/>
<apex:inputField value="{!Lead__c.CO_POSTAL__c}"/>
<apex:inputField value="{!Lead__c.CO_Social_Security_Number__c}"/>
<apex:inputField value="{!Lead__c.CO_MI__c}"/>

<apex:inputField value="{!Lead__c.CO_ST__c}"/>







<apex:inputField value="{!Lead__c.CO_Home_Phone__c}"/>
<apex:inputField value="{!Lead__c.CO_Phone_Number__c}"/>


<apex:inputField value="{!Lead__c.CO_ADDLINE2__c}"/>


<apex:inputField value="{!Lead__c.CO_CITY__c}"/>
<apex:inputField value="{!Lead__c.CO_First_Name__c}"/>

<apex:inputField value="{!Lead__c.CO_Email_Address__c}"/>
<apex:inputField value="{!Lead__c.CO_ADDLINE1__c}"/>
<apex:inputField value="{!Lead__c.CO_MAIDEN__c}"/>

<apex:inputField value="{!Lead__c.CO_DOB__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page> 

		</apex:tab>
		<apex:tab label="Banking Information" name="bankTab" id="bankTab">
			<apex:form >
			<apex:pageBlockSection >
			<apex:inputField value="{!Lead__c.Bank_Name__c}"/>
			<apex:inputField value="{!Lead__c.Account_Number__c}"/>
			<apex:inputField value="{!Lead__c.Name_On_Account__c}"/>
			<apex:inputField value="{!Lead__c.Account_Type__c}"/>
			</apex:pageBlockSection>
			</apex:form>
			</apex:tab>
			<apex:tab label="Lead Detail" name="ldTab" id="ldTab">
			<apex:form >
			<apex:pageBlockSection >
			<apex:outputField value="{!Lead__c.Id}"/>
			<apex:outputField value="{!Lead__c.CreatedBy.Name}"/>
			<apex:outputField value="{!Lead__c.LastModifiedBy.Name}"/>
			<apex:outputField value="{!Lead__c.Name}"/>
			<apex:inputField value="{!Lead__c.Owner.Name}"/>
			<apex:inputField value="{!Lead__c.Source__c}"/>
			<apex:outputField value="{!Lead__c.Lead_Age__c}"/>
			<apex:inputField value="{!Lead__c.Lead_Status__c}"/>
			<apex:inputField value="{!Lead__c.Sub_Status__c}"/>
			<apex:inputField value="{!Lead__c.Legal_Status__c}"/>
			</apex:pageBlockSection>
			</apex:form>
			</apex:tab>
				<apex:tab label="Attachments" name="attTab" id="attTab">
	
		<apex:relatedList list="NotesAndAttachments" />
			
		</apex:tab>
		
				<apex:tab label="Log" name="logTab" id="logTab">
	
		<apex:include pageName="leadHistory"> </apex:include>
			
		</apex:tab>
		
		
		
      
        
    </apex:tabPanel> 
	</apex:pageBlockSection>
    </apex:pageBlock>
	 
</apex:page>

 

Thank You in advance for any help,

 

Jason Burns

I have a simple class and vf page which creates new child custom object records. Currently you press add/remove rows to add or remove another row for a new record.

 

The parent object is lead__c, the child object is lead_debt__c. The vf page is called by a button on the lead record called add debt.

 

I am trying to default it to 7 rows and then the user can remove any rows they do not use. I cannot seem to get this to work, can someone please lead me in the right direction?

 

CLASS:

 

public class addDebt {

    public List<Lead_Debt__c> debts {get; set;}
    private final Lead__c lead;
    public addDebt(ApexPages.StandardController myController) {
        lead=(Lead__c)myController.getrecord();
        debts = new List<Lead_Debt__c>();
        Lead_Debt__c debt = new Lead_Debt__c();
        debt.Lead__c = lead.id;
        debts.add(debt);}
        
    public Lead__c getLead()
    {
    	return [SELECT First_Name__c, Name, Last_Name__c FROM Lead__c WHERE Id = :lead.Id];
    }

    public void addrow() {
        Lead_Debt__c debt = new Lead_Debt__c();
        debt.Lead__c = lead.id;
        debts.add(debt);}
            
    public void removerow(){
        Integer i = debts.size();
        debts.remove(i-1);}
            
    public PageReference save() {
    	try
    	{
        	upsert debts;
    	}
    	catch (Exception ex)
    	{
    		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Error saving debt. Please notify the systems administrator.' + ex));
    	}
    	
        //PageReference home = new PageReference('/home/home.jsp');
        //home.setRedirect(true);
        //return home; }}
        PageReference parrec = new PageReference('/'+lead.id);
        parrec.setRedirect(true);
        return parrec; 
    }
    
    public static testmethod void TestAddDebt()
    {
    	PageReference pageRef = Page.addDebt;
	    Test.setCurrentPage(pageRef);
    
    	Lead__c lead = Unit_Tests.CreateTestLead();
                
        // Add parameters to page URL      
        ApexPages.currentPage().getParameters().put('id', lead.Id); 
        
        // test all functionality     
        ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(lead);   
        addDebt dbtPage = new addDebt(sc);
        dbtPage.addrow();
        dbtPage.removerow();
        dbtPage.save(); 
    }
 }

 VF Page:

 

<apex:page standardController="Lead__c" extensions="addDebt">
    <apex:form >
    
    
    <apex:pageBlock title="Add Debt" >
    <apex:messages style="color:red;font-weight: bolder;" /> 
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
                <apex:commandButton value="Cancel" action="{!cancel}" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!debts}" var="a" id="table">
                  <apex:column headerValue="Creditor">
                    <apex:inputField value="{!a.Creditor__c}"/>
                </apex:column>
                   <apex:column headerValue="Balance">
                    <apex:inputField value="{!a.Current_Balance__c}"/>
                </apex:column>
                <apex:column headerValue="Account Number">
                    <apex:inputField value="{!a.Account_Number__c}"/>
                </apex:column>
                
               </apex:pageBlockTable>
               
               
               
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-weight:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

I am creating a tab based layout and want to embed another VF page in my tab based vf page.

 

Example:

 


<apex:tab label="Accounts" name="debtTab" id="debtTab">
<apex:relatedList list="Client_Debt1__r" />

VISUAL FORCE PAGE HERE
</apex:tab>

 

How would I do this?

 

Thank you in advance!

 

JB

I am building a tabbed layout for an application we are building,due to the large number of related objects to keep things organized.

 

We have multiple custom buttons on our custom objects which execute apex class methods and perform javascript functions. Here is an example :

 

 

{!requireScript("/soap/ajax/13.0/connection.js")} 

try
{
var leadId = "{!Lead__c.Id}";
sforce.apex.execute("ActivityClass", "AddDisposition", {recordId:leadId, objectType:"Lead"});
window.location.reload();
}
catch(err)
{
alert("Error logging disposition: " + err.toString());
}

 How would I duplicate this button in visual force?

 

I tried includng the class as an extention in the VF page:

 

<apex:page id="tabLayout" showHeader="true" standardstylesheets="false" standardController="Lead__c" extensions="ActivityClass">

 But when I call the method:

 

<apex:commandButton value="Log Disposition"  action="{!AddDisposition}"/>

 I received: Save error: /apex/tabLayoutLead @36,79 action="#{AddDisposition}": Unknown method 'Lead__cStandardController.AddDisposition()'

 

I have included both the ActivityClass and the tabbed VF page below:

 

ActivityClass:

 

/*
	Class summary: Functionality for logging dispositions on client and lead records
	Last modified by: J. Duhaney
	Last modified on: 11/8/2011
*/
global class ActivityClass {
	
	public static Boolean AddDisposition(List<Client__c> clients)
	{
		List<Task> tasks = new List<Task>();
		
		for (Client__c client : clients)
		{
			if (client.Disposition__c != null)
			{
				Task task = new Task();
				task.OwnerId = client.LastModifiedById;
				task.Subject = client.Disposition__c;
				task.WhatId = client.Id;
				task.Description = client.Notes__c;
				
				task.Priority = 'Normal';
				task.Status = 'Completed';
				task.ActivityDate = date.today();
				tasks.add(task);
				
				client.Disposition__c = '';
				client.Notes__c = '';
			}
		}
		
		insert tasks;
		update clients;
		return true;
	} 
	
	public static Boolean AddDisposition(List<Lead__c> leads)
	{
		List<Task> tasks = new List<Task>();
		
		for (Lead__c lead : leads)
		{
			Task task = new Task();
			task.OwnerId = lead.LastModifiedById;
			task.Subject = lead.Disposition__c;
			task.WhatId = lead.Id;
			task.Description = lead.Notes__c;
			
			task.Priority = 'Normal';
			task.Status = 'Completed';
			task.ActivityDate = date.today();
			tasks.add(task);
			
			lead.Disposition__c = '';
			lead.Notes__c = '';
		}
		
		insert tasks;
		update leads;
		return true;
	} 

	webservice static Boolean AddDisposition(Id recordId, String objectType)
	{
		if (objectType == 'Client')
		{
			List<Client__c> clients = [SELECT LastModifiedById, Disposition__c, Notes__c FROM Client__c 
									WHERE Id = :recordId];
		
			return AddDisposition(clients);
		}
		else if (objectType == 'Lead')
		{
			List<Lead__c> leads = [SELECT LastModifiedById, Disposition__c, Notes__c FROM Lead__c 
									WHERE Id = :recordId];
		
			return AddDisposition(leads);
		}
		else
		{
			return false;
		}
	}
	
	// Tests the add disposition functionality
	public static testMethod void TestAddDisposition()
    {    	
    	Client__c testClient = Unit_Tests.CreateTestClient();
    	testClient.Notes__c = 'Test notes';
    	testClient.Disposition__c = 'Email Sent';
    	upsert testClient;
    	
    	AddDisposition(testClient.Id, 'Client');
    	
    	Lead__c testLead = Unit_Tests.CreateTestLead();
    	testLead.Notes__c = 'Test notes';
    	testLead.Disposition__c = 'Email Sent';
    	upsert testLead;
    	
    	AddDisposition(testLead.Id, 'Lead');
    }
}

 

 

VF Tabbed Layout:

 

<apex:page id="tabLayout" showHeader="true" standardstylesheets="false" standardController="Lead__c" extensions="ActivityClass">
     <style>
     .tabStyle
     {
     	background-color: white ;
     }
    .activeTab {background-color: #1797c0 ; color:white; background-image:none}
    .inactiveTab { background-color: lightgray; color:black; background-image:none}
    </style>
    <script type="text/javascript">
function create()

window.open("{!Lead__c.Contract_URL__c}",'name','height=450,width=650');

</script>
  	    
	<apex:sectionHeader title="Lead ({!Lead__c.Name})" subtitle="{!Lead__c.First_Name__c} {!Lead__c.Last_name__c}" />
	<apex:toolbar id="theToolbar" height="50px;" itemSeparator="none" style="background-color:#1797c0;background-image:none">
        <apex:form >
        <apex:toolbarGroup itemSeparator="none" id="toobarGroupLinks">
            
            <apex:outputLabel >Disposition</apex:outputLabel>
		<apex:inputField value="{!Lead__c.Disposition__c}" style="width: 300px; height: 25px" />
		<apex:outputLabel >Disposition Notes</apex:outputLabel>
		<apex:inputField value="{!Lead__c.Notes__c}" style="width: 300px; height: 25px" />
		
        </apex:toolbarGroup>
       </apex:form>
    </apex:toolbar>   
	
	<apex:pageBlock > 
	
	 <apex:pageBlockButtons >
      <apex:form >
      <apex:commandButton value="Create Contract"  onclick="create()" />
      <apex:commandButton value="Log Disposition" action="{!AddDisposition}"/>
      </apex:form>
      </apex:pageBlockButtons> 
     
	
		<apex:pageBlockSection title="Client Information" columns="2" collapsible="true">
		<apex:outputField value="{!Lead__c.First_Name__c}" />
		<apex:outputField value="{!Lead__c.CO_First_Name__c}" />
		
		<apex:outputField value="{!Lead__c.Last_name__c}" />
		<apex:outputField value="{!Lead__c.CO_Last_Name__c}" />
		</apex:pageBlockSection>
		
		
	<apex:pageBlockSection columns="1" collapsible="true">
    <apex:tabPanel switchType="lead__c" selectedTab="actTab" id="tabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        
		<apex:tab label="Activity" name="actTab" id="actTab">
			<apex:relatedList list="OpenActivities" />
			<apex:relatedList list="ActivityHistories" />
		</apex:tab>
		<apex:tab label="Quote" name="qTab" id="qTab">
		
		<apex:relatedList list="Quote__r" />
		<apex:iframe id="q" height="520px">
			</apex:iframe>
		</apex:tab>
		<apex:tab label="Debts" name="debtTab" id="debtTab">
			<apex:include pageName="addDebt"> </apex:include>
			<apex:relatedList list="Lead_Debt__r" />
			<apex:iframe id="ld" height="350px">
			</apex:iframe>
		</apex:tab>
		<apex:tab label="Financial Profile" name="finTab" id="finTab">
			<apex:relatedList list="Financial_Profiles__r" />
			<apex:iframe id="fp" height="1050px">
			</apex:iframe>
		</apex:tab>
        <apex:tab label="Personal Information" name="piTab" id="piTab">
	
			<apex:page standardController="Lead__c">
<apex:form >

<apex:pageBlock title="Personal Information" >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:actionRegion >
<apex:pageBlockSection columns="2">
<apex:inputField value="{!Lead__c.First_Name__c}"/>
<apex:inputField value="{!Lead__c.Last_name__c}"/>
<apex:inputField value="{!Lead__c.MI__c}"/>
<apex:inputField value="{!Lead__c.Address_Line_1__c}"/>
<apex:inputField value="{!Lead__c.Address_Line_2__c}"/>
<apex:inputField value="{!Lead__c.City__c}"/>
<apex:inputField value="{!Lead__c.State__c}"/>
<apex:inputField value="{!Lead__c.Postal_Code__c}"/>
<apex:inputField value="{!Lead__c.Email_Address__c}"/>
<apex:inputField value="{!Lead__c.Best_Phone__c}"/>
<apex:inputField value="{!Lead__c.Cell_Phone__c}"/>
<apex:inputField value="{!Lead__c.Home_Phone__c}"/>
<apex:inputField value="{!Lead__c.Work_Phone__c}"/>
<apex:inputField value="{!Lead__c.MAIDEN__c}"/>
<apex:inputField value="{!Lead__c.Social_Security_Number__c}"/>
<apex:inputField value="{!Lead__c.DOB__c}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Co-Debt Information"/>
<apex:outputPanel >
<apex:inputField value="{!Lead__c.CODEBTINFO__c}">
<apex:actionSupport event="onchange" rerender="Personal Information" status="status"/>
</apex:inputField>
<apex:actionStatus startText="applying value..." id="status"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:actionRegion>

<apex:pageBlockSection rendered="{!Lead__c.CODEBTINFO__c == 'CO Info is the same'}">
<apex:inputField value="{!Lead__c.CO_Work_Phone__c}"/>
<apex:inputField value="{!Lead__c.CO_Cell_Phone__c}"/>


<apex:inputField value="{!Lead__c.CO_Work_Phone__c}"/>

<apex:inputField value="{!Lead__c.CO_Last_Name__c}"/>
<apex:inputField value="{!Lead__c.CO_POSTAL__c}"/>
<apex:inputField value="{!Lead__c.CO_Social_Security_Number__c}"/>
<apex:inputField value="{!Lead__c.CO_MI__c}"/>

<apex:inputField value="{!Lead__c.CO_ST__c}"/>







<apex:inputField value="{!Lead__c.CO_Home_Phone__c}"/>
<apex:inputField value="{!Lead__c.CO_Phone_Number__c}"/>


<apex:inputField value="{!Lead__c.CO_ADDLINE2__c}"/>


<apex:inputField value="{!Lead__c.CO_CITY__c}"/>
<apex:inputField value="{!Lead__c.CO_First_Name__c}"/>

<apex:inputField value="{!Lead__c.CO_Email_Address__c}"/>
<apex:inputField value="{!Lead__c.CO_ADDLINE1__c}"/>
<apex:inputField value="{!Lead__c.CO_MAIDEN__c}"/>

<apex:inputField value="{!Lead__c.CO_DOB__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page> 

		</apex:tab>
		<apex:tab label="Banking Information" name="bankTab" id="bankTab">
			<apex:form >
			<apex:pageBlockSection >
			<apex:inputField value="{!Lead__c.Bank_Name__c}"/>
			<apex:inputField value="{!Lead__c.Account_Number__c}"/>
			<apex:inputField value="{!Lead__c.Name_On_Account__c}"/>
			<apex:inputField value="{!Lead__c.Account_Type__c}"/>
			</apex:pageBlockSection>
			</apex:form>
			</apex:tab>
			<apex:tab label="Lead Detail" name="ldTab" id="ldTab">
			<apex:form >
			<apex:pageBlockSection >
			<apex:outputField value="{!Lead__c.Id}"/>
			<apex:outputField value="{!Lead__c.CreatedBy.Name}"/>
			<apex:outputField value="{!Lead__c.LastModifiedBy.Name}"/>
			<apex:outputField value="{!Lead__c.Name}"/>
			<apex:inputField value="{!Lead__c.Owner.Name}"/>
			<apex:inputField value="{!Lead__c.Source__c}"/>
			<apex:outputField value="{!Lead__c.Lead_Age__c}"/>
			<apex:inputField value="{!Lead__c.Lead_Status__c}"/>
			<apex:inputField value="{!Lead__c.Sub_Status__c}"/>
			<apex:inputField value="{!Lead__c.Legal_Status__c}"/>
			</apex:pageBlockSection>
			</apex:form>
			</apex:tab>
				<apex:tab label="Attachments" name="attTab" id="attTab">
	
		<apex:relatedList list="NotesAndAttachments" />
			
		</apex:tab>
		
				<apex:tab label="Log" name="logTab" id="logTab">
	
		<apex:include pageName="leadHistory"> </apex:include>
			
		</apex:tab>
		
		
		
      
        
    </apex:tabPanel> 
	</apex:pageBlockSection>
    </apex:pageBlock>
	 
</apex:page>

 

Thank You in advance for any help,

 

Jason Burns

I have a simple class and vf page which creates new child custom object records. Currently you press add/remove rows to add or remove another row for a new record.

 

The parent object is lead__c, the child object is lead_debt__c. The vf page is called by a button on the lead record called add debt.

 

I am trying to default it to 7 rows and then the user can remove any rows they do not use. I cannot seem to get this to work, can someone please lead me in the right direction?

 

CLASS:

 

public class addDebt {

    public List<Lead_Debt__c> debts {get; set;}
    private final Lead__c lead;
    public addDebt(ApexPages.StandardController myController) {
        lead=(Lead__c)myController.getrecord();
        debts = new List<Lead_Debt__c>();
        Lead_Debt__c debt = new Lead_Debt__c();
        debt.Lead__c = lead.id;
        debts.add(debt);}
        
    public Lead__c getLead()
    {
    	return [SELECT First_Name__c, Name, Last_Name__c FROM Lead__c WHERE Id = :lead.Id];
    }

    public void addrow() {
        Lead_Debt__c debt = new Lead_Debt__c();
        debt.Lead__c = lead.id;
        debts.add(debt);}
            
    public void removerow(){
        Integer i = debts.size();
        debts.remove(i-1);}
            
    public PageReference save() {
    	try
    	{
        	upsert debts;
    	}
    	catch (Exception ex)
    	{
    		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Error saving debt. Please notify the systems administrator.' + ex));
    	}
    	
        //PageReference home = new PageReference('/home/home.jsp');
        //home.setRedirect(true);
        //return home; }}
        PageReference parrec = new PageReference('/'+lead.id);
        parrec.setRedirect(true);
        return parrec; 
    }
    
    public static testmethod void TestAddDebt()
    {
    	PageReference pageRef = Page.addDebt;
	    Test.setCurrentPage(pageRef);
    
    	Lead__c lead = Unit_Tests.CreateTestLead();
                
        // Add parameters to page URL      
        ApexPages.currentPage().getParameters().put('id', lead.Id); 
        
        // test all functionality     
        ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(lead);   
        addDebt dbtPage = new addDebt(sc);
        dbtPage.addrow();
        dbtPage.removerow();
        dbtPage.save(); 
    }
 }

 VF Page:

 

<apex:page standardController="Lead__c" extensions="addDebt">
    <apex:form >
    
    
    <apex:pageBlock title="Add Debt" >
    <apex:messages style="color:red;font-weight: bolder;" /> 
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
                <apex:commandButton value="Cancel" action="{!cancel}" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!debts}" var="a" id="table">
                  <apex:column headerValue="Creditor">
                    <apex:inputField value="{!a.Creditor__c}"/>
                </apex:column>
                   <apex:column headerValue="Balance">
                    <apex:inputField value="{!a.Current_Balance__c}"/>
                </apex:column>
                <apex:column headerValue="Account Number">
                    <apex:inputField value="{!a.Account_Number__c}"/>
                </apex:column>
                
               </apex:pageBlockTable>
               
               
               
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-weight:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />                
        </div>
    </apex:pageblockButtons>  
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

I am creating a tab based layout and want to embed another VF page in my tab based vf page.

 

Example:

 


<apex:tab label="Accounts" name="debtTab" id="debtTab">
<apex:relatedList list="Client_Debt1__r" />

VISUAL FORCE PAGE HERE
</apex:tab>

 

How would I do this?

 

Thank you in advance!

 

JB