• LoveLace
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
I have a wrapper class that add rows dynamically to my visualforce page. I'm trying add row that Contain also an Attachment Input File to insert mutiple files for each row (record) apparently it's not working!
My controller class:
public class AP005ManageListController
{
public List<ExpenseWrapper> wrappers {get; set;}
public List<AttachmentWrapper> attach{get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
public AP005ManageListController()
{
  wrappers=new List<ExpenseWrapper>();
  attach= new List<AttachmentWrapper>();
  attach.add(new AttachmentWrapper());
   wrappers.add(new ExpenseWrapper(nextIdent++));
}
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new ExpenseWrapper(nextIdent++));
  }
}
public PageReference save()
{
  List<Expense__c> accs=new List<Expense__c>();
  List<Attachment> att=new List<>(Attachment);
  for (ExpenseWrapper wrap : wrappers)
  {
  for(AttachmentWrapper attWrap :attach ){
  att.add(attWrap.exp);
  }
   accs.add(wrap.acc);
  }
  insert accs;
  return new PageReference('/' + Schema.getGlobalDescribe().get('Expense__c').getDescribe().getKeyPrefix() + '/o');
}
public class ExpenseWrapper
{
  public Expense__c exp{get; private set;}
  public Integer ident {get; private set;}
  
  public ExpenseWrapper(Integer inIdent)
  {
       ident=inIdent;
       exp=new Expense__c();
  }
}
public class AttachmentWrapper {
    public Expense__c exp {get;set;}
    public Attachment att {get;set;}
    public AttachmentWrapper(Expense__c exp, Attachment att){
        this.exp = exp;
        if(att!= null){
            this.att = att;
        } else {
            this.att = new Attachment(parentId = this.att.Id);
        }
    }
}
}
My VF page:

<apex:page controller="AP005ManageListController" tabstyle="Expenses__c">
<apex:stylesheet value="{!URLFOR($Resource.styles, 'RHstyles.css')}"/>
<apex:form >
   <apex:pageBlock title="Bulk Account Create">
    <apex:pageblockSection title="Traveling Information" >
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
          
         <apex:column headerValue="Client">
            <apex:inputField value="{!wrapper.acc.Client__c}"/>
         </apex:column>
         <apex:column headerValue="Project">
            <apex:inputField value="{!wrapper.acc.Project__c}"/>
         </apex:column>
         <apex:column headerValue="Date">
            <apex:inputField value="{!wrapper.acc.Date__c}"/>
         </apex:column>
         <apex:column headerValue="Food/Meal Expenses">
            <apex:inputText value="{!wrapper.acc.Food_Expenses__c}"/>
         </apex:column>
        
         <apex:column headerValue="Phone Expenses">
            <apex:inputField value="{!wrapper.acc.Phone_Expenses__c}"/>
         </apex:column>
        <!-- <apex:column headerValue="File">
        <apex:inputFile value="{!wrapper.a.body}" filename="{!wrapper.a.name}"/>
        </apex:column>  -->
        </apex:pageblockSection>
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
            </apex:commandButton>
         </apex:column>
         
      </apex:pageBlockTable>
      <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
     
      <apex:commandButton value="Save" action="{!save}"/>
     
   
   </apex:pageBlock>
</apex:form>
</apex:page>
Hello guys,

This error is driving me crasy
arithmetic expression must use numeric argument

obj.Without_credit_time_off_amount__c =( (User.Salary__c)/30)*obj.Days__c;

Without_credit_time_off_amount__c currency type
Days__c formula field, number type
Salary__c is a currency type

I've tried to cast the salary__c value but in vain
Hello there,

I have two custom object (Employee__c[Credit__c field] and Time_Off__c{Days__c field]) with a master detail relationship (Employee__c the parent , Time_Off__c the child) once o time off is added with a number of days (Days__c) this number of days must be retreived on the employee credit (Credit__c)

Here is the apex classe I developped in order to call it in a trigger before insert/update


List<Employee__c> emp =  [SELECT Name,  (SELECT Name FROM Times_Off__r) FROM Employee__c ];
List<Employee__c> upEmpl = new List<Employee__c>();

List<Time_Off__c> TO = new List<Time_Off__c>();

public void MAJSolde(){
//List<Employee__c> empl = [SELECT Credit__c FROM Employee__c WHERE ID := Id];

for (Employee__c em: emp){
for (Time_Off__c toof: Employee__c.Times_Off__r){
    if(em.Credit__c == 0)
    System.debug('No credit left');
}
else
    em.Credit__c -= em.Times_Off__r.Days__c; 
   
}
}

Where is the probleme
Hello guys,

This error is driving me crasy
arithmetic expression must use numeric argument

obj.Without_credit_time_off_amount__c =( (User.Salary__c)/30)*obj.Days__c;

Without_credit_time_off_amount__c currency type
Days__c formula field, number type
Salary__c is a currency type

I've tried to cast the salary__c value but in vain
Hi there,

I would like to create a visualforce page that saves a single Master Opportunity with multiple Child Opportunties (Child Opportunities fields will be the same from the Master Opportunities except Account and Amount where the user can enter manually on the visualforce page).  When the user clicks on "Save" on the visualforce page, it should insert the Master Opportunity and also related Child Opportunities.

I have set up my data model. I'm using standard Opportuntiy as Child Opportunity, and has a look up field to Master Opportunity. Master Opportunitiy is a customer object which has the same fields as standard Opportunity.

I need help with the logic (controller) and I'm wondering if I could get helped on pointing in the right direction. I am thinking that in order to save Child Opportunities, the Master Opportunities should be inserted first, so that we can get the ID of the master opportunities and related to fields to save for the child opportunities. 

Thanks so much,
LZ
I'm looking to add information from the Approval History related list on the Quote object onto a custom report. 
How can this be done? 
Hello there,

I have two custom object (Employee__c[Credit__c field] and Time_Off__c{Days__c field]) with a master detail relationship (Employee__c the parent , Time_Off__c the child) once o time off is added with a number of days (Days__c) this number of days must be retreived on the employee credit (Credit__c)

Here is the apex classe I developped in order to call it in a trigger before insert/update


List<Employee__c> emp =  [SELECT Name,  (SELECT Name FROM Times_Off__r) FROM Employee__c ];
List<Employee__c> upEmpl = new List<Employee__c>();

List<Time_Off__c> TO = new List<Time_Off__c>();

public void MAJSolde(){
//List<Employee__c> empl = [SELECT Credit__c FROM Employee__c WHERE ID := Id];

for (Employee__c em: emp){
for (Time_Off__c toof: Employee__c.Times_Off__r){
    if(em.Credit__c == 0)
    System.debug('No credit left');
}
else
    em.Credit__c -= em.Times_Off__r.Days__c; 
   
}
}

Where is the probleme