Dear All,
We are running ver 2.39.1.1 and have started to experience this issue where the program stages for some TEIs do not load and throw this error in the browser console
angular.js:11655 TypeError: Cannot read properties of null (reading ‘code’)
at Object.getName (dhis2.angular.services.js:453:44)
at Object.formatDataValue (dhis2.angular.services.js:510:44)
at services.js:2473:43
at Object.r [as forEach] (angular.js:323:11)
at Object.processEvent (services.js:2466:21)
at dataentry-controller.js:1028:49
at Object.r [as forEach] (angular.js:323:11)
at $scope.getEvents (dataentry-controller.js:1001:21)
at dataentry-controller.js:954:28
at angular.js:13248:27
We noticed that this happens for both patients owned by the org unit and patients who were transferred fully by another org unit.
What we also noticed was that on changing to timeline data entry, the data entry forms open and we are able to enter data and schedule a follow-up visit but that data does not save and no new entries are made on the timeline.
Does anyone have any idea what could be going on here?
Sorry to hear your are facing this issue. The first clue from the error code is “code” do these organization units and other metadata have “code” if not could you please test and add code in the metadata?
After that please test using Guest mode (not incognito, Guest - which is different).
@Gassim The organization units have code. The code is part of the autogenerated Program ID for each patient.
Also, note that this is affecting a few patients, and not everyone enrolled.
Thanks
May I ask how this code is autogenerated? Is the Program ID a data element (or a TE attribute) that is filled using a program rule? Is it possible that for these patients there is an issue generating the value?
Does this issue happen to a user with ALL authority?
Thanks! As much detailed information would help uncover the underlaying causes to this issue, please.
Hopefully we can get a close look at these details I requested above…
Would be great if we can figure out the difference between the patients who are affected and those who aren’t. What metadata or anything that these affected patients have (or not have) that other patients who are not affected doesn’t (or does)?
Dear @Gassim, I have looked through all the data elements and ensured that code has been added to the few data elements without code.
I have also tested this in Guest mode on Chrome but the issue still persists.
I clicked on the link in the error on the console and this line in the code below was where the error was pointing to: if (keyString === options[i].code) {
getName: function getName(options, key) {
if (options) {
// for comparison with the option values, which are always represented as strings
var keyString = String(key);
// is key a code?
for (var i = 0; i < options.length; i++) {
if (keyString === options[i].code) {
return options[i].displayName;
}
}
// is key a name?
for (var i = 0; i < options.length; i++) {
if (keyString === options[i].displayName) {
return key;
}
}
// not a part of the option set
return null;
}
return key;
}
Some of the elements in the array options must be empty for some reason. Which probably means something is wrong with your metadata, becuase options is here an option set, and those should normally not contain empty elements (as far as I know).
It’s not hard at all to add a guard against this scenario in the code, and probably a lot easier than it would be for you to fix the metadata. Also others might benefit from it. But I wonder, does me making a code fix mean there will be a long delay before you get access to it because it has to go through the release system? If so it might be more interesting to figure out what the problematic option sets are and how to fix them.
@ifeanyiokoye I suggest you create a TEI for testing and try a few values in the option sets to verify that this is indeed what’s causing the error. After that the natural continuation would be to figure out which option sets are faulty and from what point in the list, but unless you have a clue about how to fix the metadata there is probably no reason to do this. On my part I’ll just add the guard I mentioned.
@ifeanyiokoye I’ve implemented the fix I had in mind. Great if you could check if it solved the problem; the latest 2.39 version of Tracker Capture can be downloaded here, and installed through the App management app. (I need your assistance for the testing because I don’t know how to reproduce the error you got. It’s not vital that you do this test though, the fix will still come out in the next release.)
Hi Tony. I think we may have multifactorial issues. I do not think some apps are updating on our instance and I do not know why. After updating the Tracker Capture app, what version should it read?
Hello Tony @superskip,
The update did not resolve it. I have started checking all the Option Sets one after the other and found this error with one of them: