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
JmBessonartJmBessonart 

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.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JmBessonartJmBessonart

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

aalbertaalbert

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? 

mikefmikef

The home page needs an '/o' at the end of the prefix.

 

 

PageReference pageRef = new PageReference('/'+ Lead.sObjectType.getDescribe().getKeyPrefix() + '/o');

 

 

 

JmBessonartJmBessonart

the problem isn't with the pageReference returned.

 

I changed to this and still throw the error msj

 

 	public void addLead () {

Lead newLead = new Lead(Email='foo@foo.com', FirstName='Foo Name', Company='Foo Company', LastName='Foo Last Name');
insert newLead;
;
}

 My controller have about 2700 lines..... If i change the object Lead to Contact, it's works!!

 

 

 	public void addLead () {

Contact newLead = new Contact(Email='foo@foo.com', FirstName='Foo firstName', LastName='foo LastName');
insert newLead;
;
}

 

 

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.....

 

JmBessonartJmBessonart

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.

 

 

 

 

 

 

 

Message Edited by JmBessonart on 02-10-2009 10:55 AM
JmBessonartJmBessonart

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!!!

 

 

This was selected as the best answer
rtuttlertuttle
I can confirm this works with cases as well.  I just like you moved the actual creation to a utility class, specifically I wrote a database insert utility class.  Not sure what ID is being used for by them, but changing to another var (used pid like you) did the trick.
Fan YangFan Yang

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!!