• Nec 123zxc
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies

Hello newbie here. I am not able to show the error from my Custom Label. Can anyone help me? Thank you so much!

 

//here is my Code

public class MyClassHandler {
  
    public static void caseValidation(List<Case> caseList){
        
        caseList = [SELECT Id, AccountId, Account.Client_Type__c from Case];
        Set<Id> caseId = new Set<Id>();
        
        for(Case caseStorage : caseList){
            caseId.add(caseStorage.AccountId);
            //system.debug('Result' + caseStorage.Id);
            
                if(caseStorage.Account.Client_Type__c == 'Silver' && caseId.size() <= 3){
                caseStorage.addError(System.Label.SilverError); //error message
            
        }
        } 
    }
}

 

//Here on the image is the main error I want to remove

User-added image

 

How to store records with limitation? Like if a user wants to store multiple data  to a certain object but the object accepts 1 record only, how to do that? Thanks!

Hello newbie here. I am not able to show the error from my Custom Label. Can anyone help me? Thank you so much!

 

//here is my Code

public class MyClassHandler {
  
    public static void caseValidation(List<Case> caseList){
        
        caseList = [SELECT Id, AccountId, Account.Client_Type__c from Case];
        Set<Id> caseId = new Set<Id>();
        
        for(Case caseStorage : caseList){
            caseId.add(caseStorage.AccountId);
            //system.debug('Result' + caseStorage.Id);
            
                if(caseStorage.Account.Client_Type__c == 'Silver' && caseId.size() <= 3){
                caseStorage.addError(System.Label.SilverError); //error message
            
        }
        } 
    }
}

 

//Here on the image is the main error I want to remove

User-added image

 

How to store records with limitation? Like if a user wants to store multiple data  to a certain object but the object accepts 1 record only, how to do that? Thanks!