• karondefranc
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Technical Lead/Architect
  • Cloud Sherpas

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Public class CustomCaseAlertsController
{
    public Case caseObj {get; set;}
    public boolean hasAlerts
    {
        get{ return (Alerts.size()==0? false: true); }
        set;
    }
    
    public integer popupWindowHeight
    {
        get{ return (230+Alerts.size()*40); }
        set;
    }
    private Set<ID> hattrixParentIds=new Set<ID>();
    private Set<ID> queryAlertIds=new set<ID>();
   
    public List<soalert__Hidden_Alert__c> Alerts {get; set;}
    private List<Hattrix_Account__c> listOfHattrixParent=new List<Hattrix_Account__c>();
    public List<soalert__Hidden_Alert__c> userSelectedAlerts=new List<soalert__Hidden_Alert__c>();
    
    public CustomCaseAlertsController(ApexPages.StandardController stdController)
    {
        String caseId = stdController.getId();
        
         Alerts = new List<soalert__Hidden_Alert__c>();
         Map<Id, soalert__Hidden_Alert__c> mapAlertIdToWrapper = new Map<Id, soalert__Hidden_Alert__c>();
        
        caseObj = [Select id,AccountId,ContactId,Site__c,Site__r.Name,CaseNumber from Case where id=:caseId];
                                     
                                   
        for(Hattrix_Account__c  idObj:[select id,Hatrix_Parent_Account__c from Hattrix_Account__c where Hatrix_Parent_Account__c =:caseObj.site__c or Hatrix_Parent_Account__c=:caseObj.accountID])
            {
                hattrixParentIds.add(idObj.id);
            }

                            
        for(soalert__Alert__c alertObj: [SELECT Id,Name,soalert__Account__c,soalert__Account__r.Name,soalert__Contact__c,soalert__Contact__r.Name,soalert__Alert_Begin_Date__c,soalert__Alert_End_Date__c,soalert__Alert_Message__c,soalert__Alert_Status__c,soalert__Case__c,soalert__User__c FROM soalert__Alert__c 
                                        Where ((soalert__Case__c=:caseObj.Id  or  soalert__Account__c=:caseObj.AccountId or soalert__Account__c=:caseobj.Site__c or  soalert__Account__c in:hattrixParentIds or soalert__Contact__c=:caseObj.ContactId) and  (soalert__Alert_Begin_Date__c <= today and soalert__Alert_End_Date__c >= today))] )
                        
        {
            soalert__Hidden_Alert__c alertWrapper = new soalert__Hidden_Alert__c();
                        
            alertWrapper.soalert__Alert__c=alertObj.Id;
            alertWrapper.soalert__Hidden__c = false;
            alertWrapper.soalert__Alert_Message__c = alertObj.soalert__Alert_Message__c;
            alertWrapper.soalert__User__c = UserInfo.getUserId(); 
                                                                                       
            if(alertObj.soalert__Account__c != null)
            {
               
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Account__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = alertObj.soalert__Account__r.Name;
                System.debug('alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel();'+alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel());
            }
            else if(alertObj.soalert__Contact__c !=null)
            {
                                 
                // alertWrapper.soalert__Object_Type__c=alertObj.soalert__Contact__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Contact__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Contact__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = alertObj.soalert__Contact__r.Name;
                            
                                  
            } 
            else if(alertObj.soalert__Case__c !=null)
            {
                System.debug('case');
                //alertWrapper.soalert__Object_Type__c=alertObj.soalert__Case__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Case__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Case__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = caseObj.CaseNumber;// need to clarify
                                          
            }
            
            mapAlertIdToWrapper.put(alertObj.Id, alertWrapper);
            
            //Alerts.add(alertWrapper);
        }
                                      
      for (soalert__Hidden_Alert__c hiddenObj: [Select id,soalert__Alert__c,soalert__User__c  from soalert__Hidden_Alert__c 
                                                    where (soalert__User__c=:UserInfo.getUserID() and soalert__Hidden__c=true 
                                                    and soalert__Alert__c in : mapAlertIdToWrapper.KeySet())])
        {
             mapAlertIdToWrapper.remove(hiddenObj.soalert__Alert__c);
        }
        
        Alerts = mapAlertIdToWrapper.values();
    }      
           
    public void hideAlerts()
    {  
        //Method for hiding the selected alerts 
        for(soalert__Hidden_Alert__c c: Alerts)
        {
            if(c.soalert__Hidden__c==true )
            {
                userSelectedAlerts.add(c);
            }
        }
        
        insert userSelectedAlerts;
    }
}
Hi All,

I have a button on Case Layout. On click of this button Visualforce page opens up in a new window. there is one button one button "OK" on the VF page. on click of this Command button VF page closes and few fields are updating back to Case. I can see fields are updating when I refresh the Case manually. I want refresh case automatically while clicking on the "OK" button and page closes.

Note: I am not using Service Console.

Kindly Help!!

Regards,
Animesh