DGB
DGB

Reputation: 5

Uncaught TypeError: Cannot read properties of null (reading 'className')

I have updated the jQuery version in the application and I am getting an error in the DatePickerComponent with jQuery 3.5.0.here i am getting error on .ClassName; i don't know what to do about it

...
else {
    if (myOwnFormat == 'HH:mm:ss' || myOwnFormat == 'HH:mm') {
        var className = document.getElementById("icon_" + pickerId).className;
        $("#icon_" + pickerId).removeClass(className).addClass("alarm_clock");
    }
    return myOwnFormat;
}

enter image description here

enter image description here

Upvotes: 0

Views: 7720

Answers (2)

As part of increasing the Security features as part of Spring 22 Release, Salesforce has moved few components to Private API. resulting which this error is being popped-up. Unfortunately this was not mentioned in the release notes, but you can find it in the console with "sfdc-lightning/charts/vbar.js has been deprecated. Please update your code to use lightning-vbar-chart".

The workaround would be using the standard 'Report Chart' component in lightning page.

Upvotes: 0

Akhilraj R
Akhilraj R

Reputation: 69

document.getElementById("icon_" + pickerId) is returning null and you are trying to get .className from null. This should fix your error.

else {
  if (myOwnFormat == 'HH:mm:ss' || myOwnFormat == 'HH:mm') {
    if(document.getElementById("icon_" + pickerId)) {
       var className = document.getElementById("icon_" + pickerId).className;
       $("#icon_" + pickerId).removeClass(className).addClass("hcm-grid_calar_saat");
    }
  }
  return myOwnFormat;
}

Upvotes: 1

Related Questions