+ Start a Discussion
jcookejcooke 

Issue with Apex Code errors when fulfilling Product Setups

After the release this weekend all of a sudden we cannot fulfill product setups we receive a "leadID" error message.
 
Here is what is going wrong:
1.There is a ‘leadId’, as well as ‘contactId’ are parameters in javascript code (that is executed first when ‘Fulfill’ button is pressed) that are passed to Apex code.
2.The leadId for a Product Setup that has no Lead is empty; technically speaking it is an empty string.
3.The exception happens when the leadId is empy.

The exception has never happened before it only happened today, and here is why:
1.There are lots of Product Setups with empty Lead Id’s that were successfully fulfilled in the past.
2.contactId – another parameter was always passed as an empty string without causing any problems. 
 

The script requires it, but the lead id can have any value, including empty string. In this case leadId is an empty string, and … it fails – but it never failed before.

Until now it worked fine, but for some unknown reason now it fails.

 

The overall point I am trying to make, is that something might have happened during the SFDC maintenance.
That ‘something’ now doesn’t let ‘sforce.apex.execute’ function to pass empty string parameters to Apex code.
ClaiborneClaiborne
An empty string is not the same as a null. Apex does not like working with null values, especially when you are comparing things or are trying to do queries with the "where" clause comparing to a "null".

My suggestion is that you go through your code and put in checks to provide alternate execution paths where leadId is null.

Something like this:

Code:
if (leadId <> null) {
   -  Old code here -
}
else {
   - New code here, accounts for null lead id value
}