Symptom
- Error seen after performing action which calls script:
- "Cannot perform runtime binding on a null reference".
Environment
SAP CPQ
Reproducing the Issue
When running actions which calls custom scripting, error is randomly thrown.
Cause
- The issue can be caused by usage of static variables within classes in IronPython scripts, combined with internal script caching, causes previously set values to persist across evaluations
- When a static variable depends on request-specific context (e.g. RequestContext.Url) and that context is null, null reference is accessed, leading to runtime binding error.
Resolution
- Identify class-level static variables in IronPython scripts that depend on request-specific context (e.g. RequestContext.Url)
- Replace those static/class-level variables with a method that computes the value at runtime
- Update all references to the former static variable to call the method instead.
Keywords
Null Reference, Static Variable, Runtime, Scripting, CPQ , KBA , CEC-SAL-CPQ , Sales Cloud CPQ , Bug Filed
Product
SAP CPQ all versions
SAP Knowledge Base Article - Public