• Fintan Murphy
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Within one of our communities we have a lightning flow that posts a case comment. It posts the comment correctly but does not trigger the notification email to the case owner.

If a user posts the case comment via the related list the email notification is sent no problem. However for our use case we can not allow community users to see the case comments as several community users may be working on the same case.

Does anyone know what the issue is?
Hi, My apex code is giving the following error; translationStatusUpdate: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.translationStatusUpdate: line 28, column 1

Here is the code snippet;
 
trigger translationStatusUpdate on Translation__c (after insert, after update) {
    
    for(Translation__c trans:Trigger.new){
        if(trans.Translation_Status__c != null && trans.Case__c != null){
            //Case[] transCase = [SELECT Id, Translation_Status__c, CaseNumber FROM Case WHERE Id = :trans.Case__r.Id LIMIT 1];
            //String CaseId = transCase.get(Id);
                       
            if(trans.Translation_Status__c == 'Completed'){
                Boolean isComplete = TRUE;
                Translation__c[] otherTransCases = [SELECT Id, Translation_Status__c FROM Translation__c WHERE Case__c = :trans.Case__c AND Id <> :trans.Id];
                for(Translation__c otherTrans:otherTransCases){
                    if(otherTrans.Translation_Status__c <> 'Completed'){
                        isComplete = FALSE;
                        break;
                    }
                }
                if(isComplete){
                    //update new Case(Id = trans.Case__r.Id, Translation_Status__c = 'Completed');
                    trans.Case__r.Translation_Status__c = 'Completed';
                }
            }
            else{
                //update new Case(Id = trans.Case__r.Id, Translation_Status__c = trans.Translation_Status__c);
                trans.Case__r.Translation_Status__c = trans.Translation_Status__c;
            }
        }
    }
}

In general what is the best way to update the field on a parent object based on a child object? The Translation_Status__c field on Translation__c is a Master-Detail relationship.
 
Within one of our communities we have a lightning flow that posts a case comment. It posts the comment correctly but does not trigger the notification email to the case owner.

If a user posts the case comment via the related list the email notification is sent no problem. However for our use case we can not allow community users to see the case comments as several community users may be working on the same case.

Does anyone know what the issue is?
Hi, My apex code is giving the following error; translationStatusUpdate: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.translationStatusUpdate: line 28, column 1

Here is the code snippet;
 
trigger translationStatusUpdate on Translation__c (after insert, after update) {
    
    for(Translation__c trans:Trigger.new){
        if(trans.Translation_Status__c != null && trans.Case__c != null){
            //Case[] transCase = [SELECT Id, Translation_Status__c, CaseNumber FROM Case WHERE Id = :trans.Case__r.Id LIMIT 1];
            //String CaseId = transCase.get(Id);
                       
            if(trans.Translation_Status__c == 'Completed'){
                Boolean isComplete = TRUE;
                Translation__c[] otherTransCases = [SELECT Id, Translation_Status__c FROM Translation__c WHERE Case__c = :trans.Case__c AND Id <> :trans.Id];
                for(Translation__c otherTrans:otherTransCases){
                    if(otherTrans.Translation_Status__c <> 'Completed'){
                        isComplete = FALSE;
                        break;
                    }
                }
                if(isComplete){
                    //update new Case(Id = trans.Case__r.Id, Translation_Status__c = 'Completed');
                    trans.Case__r.Translation_Status__c = 'Completed';
                }
            }
            else{
                //update new Case(Id = trans.Case__r.Id, Translation_Status__c = trans.Translation_Status__c);
                trans.Case__r.Translation_Status__c = trans.Translation_Status__c;
            }
        }
    }
}

In general what is the best way to update the field on a parent object based on a child object? The Translation_Status__c field on Translation__c is a Master-Detail relationship.