+ Start a Discussion
SF Beginner 2019SF Beginner 2019 

Uncaught Error in $A.getCallback() [Cannot read property 'setAttribute' of null] Callback failed: apex://LightningCheck/ACTION$UserCheck

How do i fix this issue?

({
    doInit : function(component,event,helper){
        var action = component.get("c.UserCheck");
        action.setParams({
            "currentRecordId" : component.get("v.recordId"),
            "currentUserId" : $A.get("$SObjectType.CurrentUser.Id")
        });
        action.setCallback(this,function(response){
            if(response.getState() == "SUCCESS"){
                //alert("hello there!" + response.getReturnValue()); 
                console.log(response.getReturnValue());
                if(response.getReturnValue()==true){
                    document.getElementById("Modal").setAttribute("style","height:640px;display:block;");
                    console.log(response.getReturnValue());
                }
                else{
                     document.getElementById("Modal").setAttribute("style","height:640px;display:none;");
                }
            }
        })
        $A.enqueueAction(action);
        
          var action2 = component.get("c.getAccount");
         action2.setParams({
            "currentRecordId" : component.get("v.recordId")
        });
        action2.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
               // alert("hello there!" + response.getReturnValue());
                component.set("v.account", response.getReturnValue());
                console.log(response.getReturnValue());
                /*if(response.getReturnValue()==true){
                    document.getElementById("Modal").setAttribute("style","height:640px;display:block;");
                    console.log(response.getReturnValue());
                }
                else{
                     document.getElementById("Modal_Parent").setAttribute("style","height:640px;display:none;");
                }*/
            }
         });
         $A.enqueueAction(action2); 
    
    },

 
Raj VakatiRaj Vakati
Are you testing your this component using standard alone app ?? can you please add this to the lightning record page and test it
SF Beginner 2019SF Beginner 2019
@Raj Vakati, Yes I have added this to the Lightning Record Page Layout this lightning component, and there is a random wherein the error appears when I open a record on the saleforce