1

I've got a FormAssembly form that creates a record in the EFI_Certificate__c object in Salesforce upon submit. The form accepts PayPal payments. Because the payment happens on PayPal's site, outside of FormAssembly, it creates the SF record before the person proceeds to the PayPal site for payment. Our staff needs to know when/if payment is posted so I need to be able to pass PayPal's IPN (Instant Payment Notification) that is normally posted on the FormAssembly record (once PayPal payment is complete) through to Salesforce. They have a nice article on how to do this using a VisualForce page and some apex coding. I have followed the instructions in the article, but the parmCustom variable in the apex is returning a null value instead of the value in the FormAssemblyID field. I have a included a link to the original article posted by FormAssembly, along with my apex class, VF page, and error log. Any help would be much appreciated.

https://help.formassembly.com/help/make-salesforce-and-paypal-work-together

Apex Class (IPNHandlerController)

public class IPNHandlerController {

    public PageReference myIPNupdate() {
     try{
        PageReference pageRef = ApexPages.currentPage();
        //Get the value of the 'custom' parameter from current page
        String paramCustom = pageRef.getParameters().get('custom');
        certificate = [select Id,paid__c from EFI_Certificate__c where FormAssemblyID__c = :paramCustom];

        String content = '';
        for(String key : pageRef.getParameters().keySet()){
            //Note that there is no guarantee of order in the parameter key map.
            content += key + ' : ' + pageRef.getParameters().get(key) + '\n';
        }
        certificate.PayPalInfo__c = content;
        certificate.paid__c = True;
        update certificate;

        PageReference newPage = new ApexPages.StandardController(certificate).view();
        newPage.setRedirect(true);        

        return newPage;
     } catch (System.Exception e){
         //A failure occurred
         system.debug(e);
         return null;
     }
    }

    public EFI_Certificate__c certificate {get; set;}

    public IPNHandlerController() {
    }
}

VisualForce page (IPNHandler)

<apex:page controller="IPNHandlerController" action="{!myIPNupdate}" />

Apex Log

43.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
17:34:58.0 (538115)|USER_INFO|[EXTERNAL]|005A0000000PhGW|[email protected]|Greenwich Mean Time|GMTZ
17:34:58.0 (631367)|EXECUTION_STARTED
17:34:58.0 (640269)|CODE_UNIT_STARTED|[EXTERNAL]|0662A000002Zn4D|VF: /apex/ipnhandler
17:34:58.0 (6820201)|PUSH_TRACE_FLAGS|[EXTERNAL]|01p2A000004Hegj|IPNHandlerController|APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
17:34:58.0 (6986310)|SYSTEM_MODE_ENTER|true
17:34:58.0 (7544101)|HEAP_ALLOCATE|[72]|Bytes:3
17:34:58.0 (7582302)|HEAP_ALLOCATE|[77]|Bytes:152
17:34:58.0 (7595133)|HEAP_ALLOCATE|[342]|Bytes:408
17:34:58.0 (7608139)|HEAP_ALLOCATE|[355]|Bytes:408
17:34:58.0 (7619720)|HEAP_ALLOCATE|[467]|Bytes:48
17:34:58.0 (7659053)|HEAP_ALLOCATE|[139]|Bytes:6
17:34:58.0 (7688909)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:92
17:34:58.0 (7695469)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:7
17:34:58.0 (7699284)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:2
17:34:58.0 (7721471)|METHOD_ENTRY|[1]|01p2A000004Hegj|IPNHandlerController.IPNHandlerController()
17:34:58.0 (7732073)|STATEMENT_EXECUTE|[1]
17:34:58.0 (7738189)|STATEMENT_EXECUTE|[1]
17:34:58.0 (7748062)|METHOD_EXIT|[1]|IPNHandlerController
17:34:58.0 (8004463)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
17:34:58.0 (8016225)|VARIABLE_SCOPE_BEGIN|[32]|this|IPNHandlerController|true|false
17:34:58.0 (8083355)|VARIABLE_ASSIGNMENT|[32]|this|{}|0x4a67988c
17:34:58.0 (8095725)|STATEMENT_EXECUTE|[1]
17:34:58.0 (8098380)|STATEMENT_EXECUTE|[30]
17:34:58.0 (8119645)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:6
17:34:58.0 (10166826)|STATEMENT_EXECUTE|[32]
17:34:58.0 (10445335)|POP_TRACE_FLAGS|[EXTERNAL]|01p2A000004Hegj|IPNHandlerController|APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
17:34:58.0 (10676401)|PUSH_TRACE_FLAGS|[EXTERNAL]|01p2A000004Hegj|IPNHandlerController|APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
17:34:58.0 (10759592)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
17:34:58.0 (10770212)|VARIABLE_SCOPE_BEGIN|[3]|this|IPNHandlerController|true|false
17:34:58.0 (10807035)|VARIABLE_ASSIGNMENT|[3]|this|{}|0x4a67988c
17:34:58.0 (10825571)|STATEMENT_EXECUTE|[3]
17:34:58.0 (10828420)|STATEMENT_EXECUTE|[4]
17:34:58.0 (10830729)|STATEMENT_EXECUTE|[4]
17:34:58.0 (10832839)|STATEMENT_EXECUTE|[5]
17:34:58.0 (10871007)|HEAP_ALLOCATE|[50]|Bytes:5
17:34:58.0 (10905427)|HEAP_ALLOCATE|[56]|Bytes:5
17:34:58.0 (10923598)|HEAP_ALLOCATE|[64]|Bytes:7
17:34:58.0 (11066280)|HEAP_ALLOCATE|[5]|Bytes:20
17:34:58.0 (11106526)|VARIABLE_SCOPE_BEGIN|[5]|pageRef|System.PageReference|true|false
17:34:58.0 (11522062)|VARIABLE_ASSIGNMENT|[5]|pageRef|"/apex/ipnhandler"|0x41d9e120
17:34:58.0 (11538638)|STATEMENT_EXECUTE|[7]
17:34:58.0 (11629454)|HEAP_ALLOCATE|[7]|Bytes:0
17:34:58.0 (11699437)|HEAP_ALLOCATE|[7]|Bytes:6
17:34:58.0 (11752839)|VARIABLE_SCOPE_BEGIN|[7]|paramCustom|String|false|false
17:34:58.0 (11772992)|VARIABLE_ASSIGNMENT|[7]|paramCustom|null
17:34:58.0 (11781040)|STATEMENT_EXECUTE|[8]
17:34:58.0 (11794704)|HEAP_ALLOCATE|[8]|Bytes:77
17:34:58.0 (11820179)|HEAP_ALLOCATE|[8]|Bytes:4
17:34:58.0 (11834837)|HEAP_ALLOCATE|[8]|Bytes:7
17:34:58.0 (14332924)|SOQL_EXECUTE_BEGIN|[8]|Aggregations:0|SELECT Id, paid__c FROM EFI_Certificate__c WHERE FormAssemblyID__c = :tmpVar1
17:34:58.0 (32780486)|SOQL_EXECUTE_END|[8]|Rows:926
17:34:58.0 (32820993)|HEAP_ALLOCATE|[8]|Bytes:3708
17:34:58.0 (33897895)|HEAP_ALLOCATE|[8]|Bytes:75932
17:34:58.0 (34000610)|HEAP_ALLOCATE|[8]|Bytes:3708
17:34:58.0 (34020214)|HEAP_ALLOCATE|[8]|Bytes:44
17:34:58.0 (34137597)|HEAP_ALLOCATE|[8]|Bytes:54
17:34:58.0 (34175672)|VARIABLE_SCOPE_BEGIN|[23]|e|Exception|true|false
17:34:58.0 (34375920)|VARIABLE_ASSIGNMENT|[23]|e|"common.apex.runtime.impl.ExecutionException: List has more than 1 row for assignment to SObject"|0x5f5f743e
17:34:58.0 (34389111)|STATEMENT_EXECUTE|[23]
17:34:58.0 (34391819)|STATEMENT_EXECUTE|[25]
17:34:58.0 (34456263)|USER_DEBUG|[25]|DEBUG|System.QueryException: List has more than 1 row for assignment to SObject
17:34:58.0 (34472417)|STATEMENT_EXECUTE|[26]
17:34:58.0 (34655716)|POP_TRACE_FLAGS|[EXTERNAL]|01p2A000004Hegj|IPNHandlerController|APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
17:34:58.42 (42638681)|CUMULATIVE_LIMIT_USAGE
17:34:58.42 (42638681)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 926 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

17:34:58.42 (42638681)|CUMULATIVE_LIMIT_USAGE_END

17:34:58.0 (42723288)|CODE_UNIT_FINISHED|VF: /apex/ipnhandler
17:34:58.0 (43781364)|EXECUTION_FINISHED

1 Answer 1

4

The error in the log says: System.QueryException: List has more than 1 row for assignment to SObject

If you have more than one certificate with that FormAssemblyID then that is why you are receiving the error.

On the line: certificate = [select Id,paid__c from EFI_Certificate__c where FormAssemblyID__c = :paramCustom];, if this query returns more than one record then an error will occur.

2
  • 1
    I've already queried the Certificate table, and there is only one record with the FormAssemblyID that should have been passed along. The problem is that it's showing a null value for the FormAssemblyID that it's trying to pass, of which many records have a null value (17:34:58.0 (11772992)|VARIABLE_ASSIGNMENT|[7]|paramCustom|null). Somehow the code doesn't seem to passing the FormAssemblyID field through and I'm not sure why?
    – lbyars
    Commented Oct 10, 2018 at 18:02
  • Could you post the URL of the Visualforce page when you are getting the error?
    – fred
    Commented Oct 11, 2018 at 13:39

You must log in to answer this question.

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