You need to sign in to do that
Don't have an account?
JmBessonart
UNKNOWN_EXCEPTION, invalid parameter value
Hi,
I'm triying to insert a new Lead and throw me this error message:
System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value
I have a commandButton that call the method like this:
<apex:commandButton value="ADD TO LEADS" action="{!addLead}" />
And the method:
public PageReference addLead () {
Lead newLead = new Lead(Email='foo@foo.com', FirstName='Foo Name', Company='Foo Company', LastName='Foo Last Name');
insert newLead;
PageReference pageRef = new PageReference('/'+ Lead.sObjectType.getDescribe().getKeyPrefix());
pageRef.setRedirect(true);
return pageRef;
}
Any idea??
Thanks
J.
I fixed the problem!! The problem was if i go to the page like this ..../apex/MyPage?id=XXXXXXXXX
I've changed to ..../apex/MyPage?pid=XXXXXXXXX and works fine!!!
All Answers
I was able to get that code snippet to execute properly in my Spring '09 Developer Edition org.
Is there other code that might be causing this issue?
The home page needs an '/o' at the end of the prefix.
PageReference pageRef = new PageReference('/'+ Lead.sObjectType.getDescribe().getKeyPrefix() + '/o');
the problem isn't with the pageReference returned.
I changed to this and still throw the error msj
My controller have about 2700 lines..... If i change the object Lead to Contact, it's works!!
I think is the same problem that http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=1749 but i'm not found what cause the problem.....
i've moved the method to an external class:
public class UtilClass {
public static void addLead() {
Lead newLead = new Lead (FirstName='Foo firstName', LastName='foo LastName', Company ='foo Company');
insert newLead;
}
}
EXAMPLE 1
After that, i've created this class :
public class test1 {
public void addLead () {
UtilClass.addLead();
}
}
And this page:
<apex:page controller="test1">
<apex:form >
<apex:commandButton action="{!addLead}" value="Add Lead"/>
</apex:form>
</apex:page>
EXAMPLE 2
public class test2 {
....
...
....
..
public void addLead () {
UtilClass.addLead();
}
....
....
...
}
(My class have about 2700 lines)
<apex:page controller="test2">
<apex:form >
<apex:commandButton action="{!addLead}" value="Add Lead"/>
</apex:form>
</apex:page>
I'm trying to figure out why it works in the EXAMPLE 1, and doesn't in the EXAMPLE 2. Any Idea??
J.
I fixed the problem!! The problem was if i go to the page like this ..../apex/MyPage?id=XXXXXXXXX
I've changed to ..../apex/MyPage?pid=XXXXXXXXX and works fine!!!
Confirmed the bug still exists!!:smileymad: and if have Phone (field), will get another weird error: Please Enter A Valid Phone Number Including Area Code!!