6

Recently I have hit an error as described below:

Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY Message: npe03.RecurringDonations: execution of AfterInsert caused by: System.NullPointerException: Argument 1 cannot be null (npe03)

I'm writing in PHP, and this is what my array looks like:

$newRecurring = array();
$newRecurring['Name'] = "Recurring: {$recurring['id']}";
$newRecurring['npe03__Amount__c'] = $recurring['amount'];
$newRecurring['npe03__Date_Established__c'] = date('Y-m-d', strtotime($recurring['date']));
$newRecurring['npe03__Installment_Period__c'] = 'Monthly';
$newRecurring['npe03__Organization__c'] = $account; //I double checked, it is a valid Id

Can anyone help me ?

2
  • Am I correct in assuming you're using the Salesforce Nonprofit Starter Pack and the RecurringDonations trigger code looks something like this: code.google.com/p/npsp/source/browse/recurringdonations/tags/… ?
    – JCD
    Feb 28, 2013 at 16:07
  • Yes, I'm using Salesforce NonProfit Starter Pack, and I wrote my own php code, send the insert through API : /services/data/v20.0/sobjects/npe03__Recurring_Donation__c/
    – Steve Wu
    Feb 28, 2013 at 16:20

2 Answers 2

3

From the RecurringDonations trigger code I linked in my comment above (which subsequently calls the RecurringDonations class), it seems that on line 131 it's calling Decimal.valueOf(r.Installments__c). Neglecting to pass in a value for the Installments__c field would give you the error you're seeing. I'm not very familiar with the NPSP, but just because this field isn't required in the object definition doesn't mean they didn't make it required at the page layout level. This could just be something Salesforce overlooked when they wrote that trigger by not checking for null.

Try giving Installments__c a value in your request and see if that resolves the issue.

Update: Just as I suspected, Salesforce makes the Installments__c field required on the page layout, but I suppose they never considered the case where these records would be created from an API call or DataLoader insert. In any event, you'll need to pass this field along in your request as I previously suggested (or you could add a workflow rule or bit of before-insert trigger code to give that field a default value, since this error is thrown by the after-insert execution of the trigger).

<layoutItems>
    <behavior>Required</behavior>
    <field>Installments__c</field>
</layoutItems>
4
  • I work at the Salesforce.com Foundation and I've passed your comment along to the Nonprofit Starter Pack Product Manager, Kevin Bromer.
    – greenstork
    Feb 28, 2013 at 17:36
  • @greenstork Thanks, that was quick! Please let me know if anything I mentioned is incorrect, as I based my response off of the code I linked - this may not be the latest version of the NPSP.
    – JCD
    Feb 28, 2013 at 18:55
  • @greenstork I'm now looking at the latest version of the NPSP found here (github.com/SalesforceFoundation/Recurring_Donations) and it looks like the problem I outlined in my answer has been fixed in a subsequent version. I haven't seen any code in the new version that would throw this error, so it's possible OP is using an outdated version.
    – JCD
    Feb 28, 2013 at 19:06
  • @greenstork I have a feeling that this error was caused due to my out of date Recurring Donation package. When I tried to install a updated package from AppExchange Market, I get this error after I login: Package not found
    – Steve Wu
    Feb 28, 2013 at 19:10
3

In the most recent versions (2.0+), installments will actually be calculated for you based on the forecast months configured in the settings. What's likely causing your problem is not providing a value for Open_Ended_Status__c, which defines how the Recurring Donation is treated (if you're using a version prior to 2.0, this field won't be available). In v2.0+, you can choose to use open-ended donations (where a set of Opportunities are maintained out into the future, providing limitless recurrance), or the standard recurring donations behavior that was present based in pre-2.0 versions. Either way, you'll need to set the Open_Ended_Status__c field.

For backwards compatibility, the field is not required at the DB level, but is required on the layout, similar to what JCD indicated above.

The update link here should get you the most recent version as well: Recurring Donations Update Link

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .