You need to sign in to do that
Don't have an account?

Error inserting lead
I am trying to create a new lead from inside an Apex Controller. For test purposes, I am simply running the following code:
insert new Lead(LastName='Smite', Company='Acme');
This works fine when run from an execure anonymous window, but when it runs in my controller I always get:
System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value: []
Error is in expression '{!createLead}' in component <apex:commandButton> in page prospects
Why would this be happending? I have no triggers or workflows defined.
Any help is greatly appreciated.
insert new Lead(LastName='Smite', Company='Acme');
This works fine when run from an execure anonymous window, but when it runs in my controller I always get:
System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value: []
Error is in expression '{!createLead}' in component <apex:commandButton> in page prospects
Why would this be happending? I have no triggers or workflows defined.
Any help is greatly appreciated.
also can you try changing the line to
Lead l = new Lead(LastName='Smite', Company='Acme');
insert l;
Page----
<apex:page controller="isertLead">
<apex:form >
<apex:inputText value="{!Lname}" label="Lname"/>
<apex:inputText value="{!Status}" label="Status"/>
<apex:inputText value="{!Company}" label="Company"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:form>
</apex:page>
Controller--------------
public class isertLead {
public string Lname{get;set;}
public string Status{get;set;}
public string Company{get;set;}
public void save()
{
Lead l=new Lead();
l.lastname=Lname;
l.Status=Status;
l.Company=Company;
insert l;
}
}