function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marcela SanchezMarcela Sanchez 

as I can pass the name of travel in the Field?

I have a problem with my code, and I can move or drag the name of the travel to my window "New Expenses", what I did here was to make a window where you can add multiple Expenses in one window, but in my code if I put <apex:inputfield value="{!Expenses__c.Travels__c}" required="true"/> drag me the name of the travel but when I get the expenditure does not keep in my travel.
As I can do to have the name of the travel there and save me the cost I do?

This is my code:

<apex:page StandardController="Expenses__c" extensions="AddExpenses" id="thePage" docType="html-5.0">

<apex:form >
<apex:sectionheader title="{!$ObjectType.Expenses__c.label} Edit" subtitle="{!IF(ISNULL(Expenses__c.Name), 'New Expenses',Expenses__c.Name)}"/>

<apex:pageblock id="pb1">
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:pageblock id="pb" title="New Expenses">
   
    <apex:pageBlockButtons >
      
        <apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
        
        <apex:commandbutton value="Save" action="{!Save}"/>
     
        <apex:commandButton value="Reset" status="idStatus" onclick="this.form.reset();return false;"/>
        
        <apex:commandbutton value="Back to travel" action="{!Cancel}"/> 
        
               
        </apex:pageBlockButtons>

        <apex:outputpanel >
                <apex:pageblocksection title="Information" showheader="true" columns="2">
                
                
                <apex:inputfield value="{!e1.acct.Travels__c}" required="true"/>
              
                 
                
                <apex:pageblocksectionitem />
                </apex:pageblocksection>
                  
                    <apex:pageblocksection title="Relation" showheader="true" columns="3">
                    
                    <apex:inputfield value="{!e1.acct.Parent_Customer__c}" required="false"/> 
                    <apex:inputfield value="{!e1.acct.Corporate__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Suspect__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Campaign__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Prospect__c}" required="false"/>
                    <apex:pageblocksectionitem />
                </apex:pageblocksection>
                <apex:pageblocksection title="Concept & Monetary" showheader="true" columns="5">
                    <apex:inputfield value="{!e1.acct.Name}" required="true"/>
                    <apex:inputfield value="{!e1.acct.Currency__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Date__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Amount__c}" required="true"/>
                    <apex:inputfield value="{!e1.acct.Entry__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.IVA__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Entry_Type__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Tips__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Other_specify__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Billed_To__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Payment_Method__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Invoice__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Description__c}" required="false"/>
                    <apex:pageBlockSectionItem >

  

 

  </apex:pageBlockSectionItem>
                </apex:pageblocksection>
                <apex:pageblocksection title="Detailed Transport (If Apply)" showheader="true" columns="3">
                    <apex:inputfield value="{!e1.acct.Taxi_from__c}" required="false"/>
                    <apex:inputfield value="{!e1.acct.Taxi_to__c}" required="false"/>
               
                </apex:pageblocksection> 
            </apex:outputpanel>
        
           
        </apex:pageblock>

</apex:repeat>
</apex:pageBlock>        
</apex:form>
</apex:page>


///////////////// Controller//////////////////

public class AddExpenses {

 public List<Expenses__c>lstAcct = new List<expenses__c>();
   
    public List<innerClass> lstInner
    {   get;set;    } 
    
    public String selectedRowIndex  
    {get;set;}  
    
    
    public Integer count = 1;
        
    public PageReference Save()
    {
      
    PageReference pr = new PageReference('/apex/Expense');
                                            
        for(Integer j = 0;j<lstInner.size();j++)
        {
            lstAcct.add(lstInner[j].acct);
        } 
        insert lstAcct;
        
      return pr;
    } 
  
   public void Add()
    {   
        count = count+1;
        addMore();      
    }
    
      
    public void addMore()
    {
      
        innerClass objInnerClass = new innerClass(count);
        
        
        lstInner.add(objInnerClass);    
        system.debug('lstInner'+lstInner);            
    }
    
  
    public AddExpenses(ApexPages.StandardController ctlr)
    {
    
        lstInner = new List<innerClass>();
        addMore();
        selectedRowIndex = '0';
 
        
    }
         
    public class innerClass
    {       
       
        public String recCount
        {get;set;}
        
        
        public expenses__c acct 
        {get;set;}
              
        public innerClass(Integer intCount)
        {
            recCount = String.valueOf(intCount);        
                   
          acct = new expenses__c();
                  
    }     
           
    }

}





 
James LoghryJames Loghry
Daniel,

What exactly are you asking, and what exactly is the issue you are having here?  It's not clear at all what your ask is.

Please reply with a better description.  Also, when you post any code or markup, please use the code format (< >) button.  This button helps format the code and allows us to copy and paste the code for our solutions, if necessary.

Thank you.