Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to solve error 'Cannot index into a null value (COMMON_SERVER_ERROR)'?

This error occurs if the null check condition is not added for the fields or custom forms (that are non-mandatory) used in any of the edit check rules present in the workflow. Hence, before accessing such fields/forms, we must put a ‘not null’ check.
This check is defined in the ‘when’ part of the edit check syntax.


Here is an example:
Checking the combination of ‘Primary Site’ values from the ‘Demo Pathology’ form concerning participant gender.
We need to check that the form is filled and the ‘Primary Site’ value exists by adding the ‘not null’ condition in the ‘when’ part of the edit check.
"when" : "#cpr.participant.gender == 'Female' && #cpr.registrationDate != null && #visit.visitDate != null && #visitForms['demoPathologyForm'] != null && #visitForms['demoPathologyForm']['primarySite'] != null"

 

{ "records" : [ "cpr", "visit" ], "forms" : { "visit" : [ "demoPathologyForm" ] }, "rules" : [ { "when" : "#cpr.participant.gender == 'Female' && #cpr.registrationDate != null && #visit.visitDate != null && #visitForms['demoPathologyForm'] != null && #visitForms['demoPathologyForm']['primarySite'] != null", "expr" : "!{'Penis, NOS', 'Prostate gland', 'Testis, NOS', 'Scrotum, NOS', 'Male genital organs, NOS'}.contains(#visitForms['demoPathologyForm']['primarySite'])", "description" : "Check the Primary Site values with respect to gender" } ] }

Please note that even if the null check is missed in any of the edit checks, it will give an error for all the pages included in the edit check block whenever the user tries to add/update any data. So make sure that all the non-mandatory fields/forms are checked for being ‘NOT NULL’.

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com