You need to sign in to do that
Don't have an account?
Semira@gmail.com
Visualforce Error: Formula Expression is required on the action attributes.
Hi, I have a requirement to write an extension that will create multiple records by cloning the records and inserting different contacts with one click of a button.
So I wrote my controller going through for loop that will look for more records in a list, insert the contact and parent ID and then clone the record. But maybe this is not the way to do it? I'm getting Visualfoce error. I have no idea what it means. My page reference looks correct.
Please help! It is kind of urgent so any help is appreciated.
Here's my controller:
public class ContactInsert
{
public List<Expense_Line_Item__c> expense {get; set;}
private final Expense_Line_Item__c LI;
public ContactInsert(ApexPages.StandardController myController) {
this.LI = (Expense_Line_Item__c)myController.getRecord();
expense = new List<Expense_Line_Item__c>();
//addrow();
}
public void addrow(){
Expense_Line_Item__c exp = new Expense_Line_Item__c();
expense.add(exp);
}
public void removerow(){
Integer i = expense.size();
expense.remove(i-1);}
public PageReference save() {
/* List<Expense_Line_Item__c> listexpense = new List<Expense_Line_Item__c>();
*/
Account acct = [Select id, name from Account where id=:LI.expense__c];
//Contact con =[Select id, name from Contact where id=:LI.contact__c];
//Expense_Line_Item__c exp = new Expense_Line_Item__c();
for(Expense_Line_Item__c exp :expense)
{
Contact con =[Select id, name from Contact where id=:LI.contact__c];
LI.expense__c = acct.ID;
LI.contact__c = con.ID;
expense.clone();
}
Integer count = 0;
count = expense.size();
system.debug('count:::::::::::::::::::'+count);
//expense[0].test_c = LI.expense_c;
insert expense;
PageReference parrec = new PageReference('/apex/expense');
parrec.setRedirect(true);
return parrec; }
}
Here's my Visualforce Page:
<apex:page StandardController="Expense_Line_Item__c" extensions="ContactInsert" standardStylesheets="true" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:inputField value="{!Expense_Line_Item__c.Expense__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Name}"/>
<apex:inputField value="{!Expense_Line_Item__c.Date_of_Expense__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Contact__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Amount__c}"/>
</apex:pageblockSection>
<apex:actionRegion immediate="true">
<apex:pageBlockSection title="Additional Contacts" >
<apex:commandButton value="Add Contact" action="{!addrow}" reRender="table"/>
<br/>
<br/>
<apex:pageBlockTable value="{!expense}" var="a" id="table">
<apex:column headerValue="Contact">
<apex:inputField value="{!a.Contact__c}" required="false"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>
What am I doing wrong???
So I wrote my controller going through for loop that will look for more records in a list, insert the contact and parent ID and then clone the record. But maybe this is not the way to do it? I'm getting Visualfoce error. I have no idea what it means. My page reference looks correct.
Please help! It is kind of urgent so any help is appreciated.
Here's my controller:
public class ContactInsert
{
public List<Expense_Line_Item__c> expense {get; set;}
private final Expense_Line_Item__c LI;
public ContactInsert(ApexPages.StandardController myController) {
this.LI = (Expense_Line_Item__c)myController.getRecord();
expense = new List<Expense_Line_Item__c>();
//addrow();
}
public void addrow(){
Expense_Line_Item__c exp = new Expense_Line_Item__c();
expense.add(exp);
}
public void removerow(){
Integer i = expense.size();
expense.remove(i-1);}
public PageReference save() {
/* List<Expense_Line_Item__c> listexpense = new List<Expense_Line_Item__c>();
*/
Account acct = [Select id, name from Account where id=:LI.expense__c];
//Contact con =[Select id, name from Contact where id=:LI.contact__c];
//Expense_Line_Item__c exp = new Expense_Line_Item__c();
for(Expense_Line_Item__c exp :expense)
{
Contact con =[Select id, name from Contact where id=:LI.contact__c];
LI.expense__c = acct.ID;
LI.contact__c = con.ID;
expense.clone();
}
Integer count = 0;
count = expense.size();
system.debug('count:::::::::::::::::::'+count);
//expense[0].test_c = LI.expense_c;
insert expense;
PageReference parrec = new PageReference('/apex/expense');
parrec.setRedirect(true);
return parrec; }
}
Here's my Visualforce Page:
<apex:page StandardController="Expense_Line_Item__c" extensions="ContactInsert" standardStylesheets="true" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:inputField value="{!Expense_Line_Item__c.Expense__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Name}"/>
<apex:inputField value="{!Expense_Line_Item__c.Date_of_Expense__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Contact__c}" />
<apex:inputField value="{!Expense_Line_Item__c.Amount__c}"/>
</apex:pageblockSection>
<apex:actionRegion immediate="true">
<apex:pageBlockSection title="Additional Contacts" >
<apex:commandButton value="Add Contact" action="{!addrow}" reRender="table"/>
<br/>
<br/>
<apex:pageBlockTable value="{!expense}" var="a" id="table">
<apex:column headerValue="Contact">
<apex:inputField value="{!a.Contact__c}" required="false"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:actionRegion>
</apex:pageBlock>
</apex:form>
</apex:page>
What am I doing wrong???
Change the method name to something else and see..instead of save().
Thanks,
All Answers
Change the method name to something else and see..instead of save().
Thanks,