• Clement Debrueres-Bartoli
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
Hi Salesforce friends,

I am still a beginner with Apex class and I have a requirement to create a VF page showing all the open cases of the Acount.

My VF page is
<apex:page standardController="Case" extensions="ShowCustomersOpenCases">
<apex:form > 
<apex:pageBlock >
<apex:pageBlockTable value="{!CA}" var="C" columnsWidth="1%,1%,1%" >                                                     
                <apex:column headerValue="Case Number" >
                <apex:commandLink value="{!C.CaseNumber}" action="/{!C.Id}" target="_blank" />
                </apex:column>                
                <apex:column headerValue="Status" value="{!C.Status}" />
                <apex:column headerValue="Created Date" value="{!C.CreatedDate}" />       
</apex:pageBlockTable>               
</apex:pageBlock>
</apex:form>
</apex:page>
My Apex Controller is
 
public with sharing class ShowCustomersOpenCases {

    public List<Case> CA { get; private set; }

    public ShowCustomersOpenCases(ApexPages.StandardController controller) {
        controller.addFields(new List<String>{ 'AccountId' });
        Case currentCase = (Case)controller.getRecord();
        CA = [Select Id, CaseNumber, CreatedDate, Status, Subject, ContactId FROM Case Where Status <> 'Closed' AND AccountId = :currentCase.AccountId and Id != :currentCase.Id Order by CreatedDate DESC Limit 100];
      }
}

But I dont manage to create a proper Test Class, after a lot of attempts.

Any good soul who could help me with that test Class?

Thank you very much
​​​​​​​
 
Hi Salesforce fellas,

I have a requirement to create a VF page to display a list of all Cases of the Account, where Status is not "Closed.

My VF page code is
<apex:page controller="CustomersOpenCases">
    <apex:form >
        <apex:pageBlock title="Open Cases" id="cases_list">
            <apex:repeat value="{!newCases}" var="case" id="case">
                <p><apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink> &nbsp;&nbsp;
                <apex:outputLink value="/{!case.Id}">{!case.Status}</apex:outputLink></p>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My Apex controller Class is:
 
public class CustomersOpenCases {

    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Status ' +
            'FROM Case ' +
            'WHERE Status = \'New\' OR Status = \'Reopen\' OR Status = \'Waiting\' '
        );
   
    return results;
    }

}

But after a lot of attempts I dont manage to create the Test Class for it.

Any idea on how I should create the corresponding Test Class ?

Thank you very much,

Clement 
Hi Salesforce fellas,

I am still a beginner with Case Triggers and I would like to create an Apex Trigger that would update the children cases everytime the parent case is updated (any update on any field of the Parent).
* To make the parent-child relationship, I just use the standard method and enter the Parent Case number in "Parent Case" field of the Child Case.

The Children Cases would have their following fields updated with the value in the Parent Case:
Status, ClosedDate, Category, SubCategory, SubCategory2, Category_Bank, SubCategory_Bank

I made this Case Trigger  but it just does not work, and it is only when Parent Case ' Status' field is updated to "Closed"
 
trigger updateChildCases on Case (after update) {
  

        List<Case> childrenToUpdate = new List<Case>();
        Set<Id> parentIds = new Set<Id>();
        for(Case p:trigger.new) {
        
            if(p.IsClosed == TRUE) {
                parentIds.add(p.Id);
            }
        }
        if(parentIds.size() > 0) {
            for(Case ch : [SELECT Id, 
            Parent.Status,
            Parent.ClosedDate,
            
            Parent.Category__c,
            Parent.SubCategory_2__c, 
            Parent.SubCategory__c,
            
            Parent.Category_Bank__c,
            Parent.SubCategory_Bank__c  
            
            FROM Case WHERE Parent.Id IN :parentIds
            AND Parent.Status <> NULL
            AND PArent.ClosedDate <> NULL
            
            AND Parent.Category__c <> NULL
            AND Parent.SubCategory__c <> NULL
            AND Parent.SubCategory_2__c <> NULL
            
            AND Parent.Category_Bank__c <> NULL
            AND Parent.SubCategory_Bank__c <> NULL
            ]) {
 
                ch.Status = ch.Parent.Status;                 ch.ClosedDate = ch.Parent.ClosedDate;                 ch.Category__c = ch.Parent.Category__c;                 ch.SubCategory__c = ch.Parent.SubCategory__c;                 ch.SubCategory_2__c = ch.Parent.SubCategory_2__c;                ch.Category_Bank__c = ch.Parent.Category_Bank__c;                ch.SubCategory_Bank__c = ch.Parent.SubCategory_Bank__c;
 
                childrenToUpdate.add(ch);
            } 
Update childrenToUpdate;
            }
        }
my test class is probably incomplete:
@isTest
private class UpdateChildCases_Test {
 
  static testMethod void Test(){
            
    Case curCase = new Case(Status = 'Closed',
    Category__c ='Registration',
    SubCategory__c = 'Open/Reopen Account',
    SubCategory_2__c = 'Create Profile',
    Category_Bank__c = '1',
    SubCategory_Bank__c = '2' );
    insert curCase;
    
    Case curCase2 = new Case(Status='New',ParentId=curCase.Id);
    insert curCase2;

       Test.StartTest(); 
 
    Test.StopTest();
  }
}
(sorry if the code burns your eyes )

I get some code coverage and no error when I save the trigger and the test class, but then when I go back to my cases and try to close a Parent Case it just does not update the Child Case.

Any good soul who could help me with that please?

Thank you very much :)
Hello fellas,

For my spam emails, I currently have this process for Cases:

-if Custom field "Mark as Spam" is ticked by User, then move the Case to "Spam" queue and mark the Status as "Closed"

This PB works well, no problem. All my Spams go to this queue, in Closed status.

However I would also like to integrate the deletion of those Cases in the process: Case should be deleted 4 hours after they have been moved and closed. (I dont want to delete immediately, I need the Case to stay a few hours in the queue)

There are several options, but which one would be the simplest and cleanest to achieve this regular deletion of spam cases?

Thank you very much
Hello folks,

When a chat is requested by a customer, this customer is assigned to a Live Chat Visitor name, which attributes an ID number to customer's device. Basically, same device would always have the same ID and it cannot really fail.

In order to avoid that a customer hits the chat button twice, is it possible to setup a logic that would say "if Live Chat Visitor XXX already has an active ongoing chat, this same Visitor cannot hit the chat button again to open a second chat or Chat cannot be initiated if Live Chat Visitor has an ongoing chat"

Thank you for your help
Hello,
When a Chat Transcript is created, a Live Chat Transcript Events log is created and attached to the Chat Transcript.
Is there any way to delete these Transcripts Events, ideally 10 days after the Chat has happened?
Is there a way to create a scheduled job deleting the Transcript Events automatically ?

The reason is I dont need these Transcript Events after 10 days, and they consume serious storage space.

Thank you,
Hi Salesforce friends,

I am still a beginner with Apex class and I have a requirement to create a VF page showing all the open cases of the Acount.

My VF page is
<apex:page standardController="Case" extensions="ShowCustomersOpenCases">
<apex:form > 
<apex:pageBlock >
<apex:pageBlockTable value="{!CA}" var="C" columnsWidth="1%,1%,1%" >                                                     
                <apex:column headerValue="Case Number" >
                <apex:commandLink value="{!C.CaseNumber}" action="/{!C.Id}" target="_blank" />
                </apex:column>                
                <apex:column headerValue="Status" value="{!C.Status}" />
                <apex:column headerValue="Created Date" value="{!C.CreatedDate}" />       
</apex:pageBlockTable>               
</apex:pageBlock>
</apex:form>
</apex:page>
My Apex Controller is
 
public with sharing class ShowCustomersOpenCases {

    public List<Case> CA { get; private set; }

    public ShowCustomersOpenCases(ApexPages.StandardController controller) {
        controller.addFields(new List<String>{ 'AccountId' });
        Case currentCase = (Case)controller.getRecord();
        CA = [Select Id, CaseNumber, CreatedDate, Status, Subject, ContactId FROM Case Where Status <> 'Closed' AND AccountId = :currentCase.AccountId and Id != :currentCase.Id Order by CreatedDate DESC Limit 100];
      }
}

But I dont manage to create a proper Test Class, after a lot of attempts.

Any good soul who could help me with that test Class?

Thank you very much
​​​​​​​
 
Hi Salesforce fellas,

I have a requirement to create a VF page to display a list of all Cases of the Account, where Status is not "Closed.

My VF page code is
<apex:page controller="CustomersOpenCases">
    <apex:form >
        <apex:pageBlock title="Open Cases" id="cases_list">
            <apex:repeat value="{!newCases}" var="case" id="case">
                <p><apex:outputLink value="/{!case.Id}">{!case.CaseNumber}</apex:outputLink> &nbsp;&nbsp;
                <apex:outputLink value="/{!case.Id}">{!case.Status}</apex:outputLink></p>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

My Apex controller Class is:
 
public class CustomersOpenCases {

    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Status ' +
            'FROM Case ' +
            'WHERE Status = \'New\' OR Status = \'Reopen\' OR Status = \'Waiting\' '
        );
   
    return results;
    }

}

But after a lot of attempts I dont manage to create the Test Class for it.

Any idea on how I should create the corresponding Test Class ?

Thank you very much,

Clement 
Hi Salesforce fellas,

I am still a beginner with Case Triggers and I would like to create an Apex Trigger that would update the children cases everytime the parent case is updated (any update on any field of the Parent).
* To make the parent-child relationship, I just use the standard method and enter the Parent Case number in "Parent Case" field of the Child Case.

The Children Cases would have their following fields updated with the value in the Parent Case:
Status, ClosedDate, Category, SubCategory, SubCategory2, Category_Bank, SubCategory_Bank

I made this Case Trigger  but it just does not work, and it is only when Parent Case ' Status' field is updated to "Closed"
 
trigger updateChildCases on Case (after update) {
  

        List<Case> childrenToUpdate = new List<Case>();
        Set<Id> parentIds = new Set<Id>();
        for(Case p:trigger.new) {
        
            if(p.IsClosed == TRUE) {
                parentIds.add(p.Id);
            }
        }
        if(parentIds.size() > 0) {
            for(Case ch : [SELECT Id, 
            Parent.Status,
            Parent.ClosedDate,
            
            Parent.Category__c,
            Parent.SubCategory_2__c, 
            Parent.SubCategory__c,
            
            Parent.Category_Bank__c,
            Parent.SubCategory_Bank__c  
            
            FROM Case WHERE Parent.Id IN :parentIds
            AND Parent.Status <> NULL
            AND PArent.ClosedDate <> NULL
            
            AND Parent.Category__c <> NULL
            AND Parent.SubCategory__c <> NULL
            AND Parent.SubCategory_2__c <> NULL
            
            AND Parent.Category_Bank__c <> NULL
            AND Parent.SubCategory_Bank__c <> NULL
            ]) {
 
                ch.Status = ch.Parent.Status;                 ch.ClosedDate = ch.Parent.ClosedDate;                 ch.Category__c = ch.Parent.Category__c;                 ch.SubCategory__c = ch.Parent.SubCategory__c;                 ch.SubCategory_2__c = ch.Parent.SubCategory_2__c;                ch.Category_Bank__c = ch.Parent.Category_Bank__c;                ch.SubCategory_Bank__c = ch.Parent.SubCategory_Bank__c;
 
                childrenToUpdate.add(ch);
            } 
Update childrenToUpdate;
            }
        }
my test class is probably incomplete:
@isTest
private class UpdateChildCases_Test {
 
  static testMethod void Test(){
            
    Case curCase = new Case(Status = 'Closed',
    Category__c ='Registration',
    SubCategory__c = 'Open/Reopen Account',
    SubCategory_2__c = 'Create Profile',
    Category_Bank__c = '1',
    SubCategory_Bank__c = '2' );
    insert curCase;
    
    Case curCase2 = new Case(Status='New',ParentId=curCase.Id);
    insert curCase2;

       Test.StartTest(); 
 
    Test.StopTest();
  }
}
(sorry if the code burns your eyes )

I get some code coverage and no error when I save the trigger and the test class, but then when I go back to my cases and try to close a Parent Case it just does not update the Child Case.

Any good soul who could help me with that please?

Thank you very much :)
Hello fellas,

For my spam emails, I currently have this process for Cases:

-if Custom field "Mark as Spam" is ticked by User, then move the Case to "Spam" queue and mark the Status as "Closed"

This PB works well, no problem. All my Spams go to this queue, in Closed status.

However I would also like to integrate the deletion of those Cases in the process: Case should be deleted 4 hours after they have been moved and closed. (I dont want to delete immediately, I need the Case to stay a few hours in the queue)

There are several options, but which one would be the simplest and cleanest to achieve this regular deletion of spam cases?

Thank you very much