• umakanth mettu
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi All,
we want to activate the chatter for email to case in lightning but we do not want any person to post or comment using chatter.
I have written two triggers for not posting anything and also commenting via case feed both are working fine but failed to write a test classes for both.
FeedItem:
trigger ChatterCommentItem on FeedItem (before insert) {
for(FeedItem fi : trigger.new)
        if(fi.type == 'ContentPost' || fi.type == 'TextPost')
            fi.addError('you do not have permissions to post any comment or File.Please contact your system administrator.');
}
FeedComment
trigger ChatterComment on FeedComment (Before Insert) { 
    for(FeedComment fc : trigger.new)
if(fc.CommentType == 'ContentComment' || fc.CommentType == 'TextComment' )
            fc.addError('you do not have permissions to post any comment or File.Please contact your system administrator.');
}

I have written feed comment trigger for case object when the case status or any changes happens case feed is generated so no one should comment on it any help on the test classes for both triggers would be appriciated thank you.
I am using &nbsp I do not want to use it and also why I am getting the alignment issue below is the code nad output thanks.
<apex:page extensions="HRSSLearningStandContler" standardcontroller="case" action="{!autorun}">
<script type="text/javascript">
    function confirmcancel(){
        var iscancel = confirm("Are you sure you wish to cancel?");
        if(iscancel) return true;
        
        return false;  
    }
    </script>
    <apex:form >
        <apex:pageBlock title="Learning Request" mode="edit" > <!-- id="displaystate" --> 
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <!--<apex:commandButton action="{!changeValueComponent}" value="changeValueComponent"/>-->
                <!-- <apex:commandButton action="{!save}" value="Save"/> -->
                <apex:commandButton action="{!SubmitLearningRequest}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmcancel()" immediate="true"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Case Information" columns="2">
            <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Customer Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputtext>
                    <span class="requiredInput">  
                        <div class="requiredBlock" />                     
                        <apex:inputField value="{!cas.ContactId}" rendered="{!NOT(DisplayCustomerName)}"  />  
                     </span>    
                    <apex:outputText label="Customer Name" value="{!a}" rendered="{!DisplayCustomerName}"/>                         
            </apex:outputPanel>

            <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                 <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>
                      <apex:selectList value="{!selectedCaseStatus}" > 
                          <apex:selectoptions value="{!selectedCaseStatusOptions}"/>
                      </apex:selectList>
            </apex:outputPanel>    
                <apex:inputField value="{!cas.Reported_By1__c}" rendered="{!NOT(ReadOnlyforNonAgents)}"/>
                <apex:outputText value="{!cas.Reported_By1__c}" rendered="{!ReadOnlyforNonAgents}" />
                
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56" > 
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case Category&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputtext>
                        <span class="requiredInput"> 
                            <apex:selectList value="{!selectedCaseCategory}" onchange="changeValueComponentJS();" Size="1" >
                                <div class="requiredBlock"/>
                                <apex:selectoptions value="{!selectedCaseCategoryOptions}"/>
                            </apex:selectList>
                        </span>
                </apex:outputPanel>                                


                <apex:inputField value="{!cas.Re_opened__c}"/>

            </apex:pageBlockSection>

            
            <apex:pageBlockSection title="Training Request" columns="2" >
            
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56" >
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Event Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" />                     
                            <apex:inputField value="{!cas.Event_Name__c}" />
                       </span>                                   
                </apex:outputPanel>   
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" />                     
                               <apex:inputfield id="location" value="{!cas.Location__c}"/>   
                         </span>                                   
                </apex:outputPanel>    
                <apex:inputField value="{!cas.Session_Name__c}"/>
                <apex:inputField value="{!cas.Preferred_Building__c}"/>   
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Requested Start Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" />                     
                            <apex:inputField value="{!cas.Requested_Start_Date__c}" />
                       </span>                                   
                </apex:outputPanel>     
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >Number of Sessions Required&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" />                     
                            <apex:inputField value="{!cas.Number_of_Sessions_Required__c}" />
                       </span>                                   
                </apex:outputPanel> 
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">                
                  <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Secondary Start Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                       <apex:inputField value="{!cas.Secondary_Start_Date__c}" />                                  
                </apex:outputPanel>    
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Participants per Session&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" />                     
                            <apex:inputField value="{!cas.Number_of_Participants_per_Session__c}"/>
                       </span>                                   
                </apex:outputPanel> 
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                      <span class="requiredInput">  
                            <div class="requiredBlock" /> 
                            <apex:inputField value="{!cas.Start_Time__c}" />
                       </span>     
                </apex:outputPanel>     
                <apex:outputPanel style="font-size:91%;font-weight:bold;color:#4a4a56">
                    <apex:outputText >&nbsp;&nbsp;Attending Department Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</apex:outputText>               
                        <span class="requiredInput">  
                            <div class="requiredBlock" /> 
                               <apex:inputField value="{!cas.Name_of_Department_Attending__c}" />
                       </span>                                   
                </apex:outputPanel> 

                <apex:inputField value="{!cas.Attendee_Details__c}"/>
                <apex:inputField value="{!cas.Additional_Information__c}"/>                
            </apex:pageBlockSection>
User-added image
I have implemented "liveAgent:clientChatQueuePosition" tag in a customized chat window to show the user at what place he is in Queue. When the request has been sent to the agent, however, the value is null. Do anyone let me know how when the queue position is zero another conditional message is displayed?
<tr>
 <td>
  <p style="font-size: 14px;">You are now being connected to an agent. Currently your position in the queue is <liveAgent:clientChatQueuePosition /></p>
 </td>                                               
 </tr>
Hi
Looking forward for help on below trigger I am new to salesforce and unable to achieve code coverage any help would be helpful thanks.

Trigger populate_Case_Queue_OR_Owner_Name on SLA_History__c(Before Insert,before update)
{
    IF(Trigger.isBefore && (Trigger.isInsert )){
        system.debug('+++++++before insert+++++');
        Set<Id> caseIds = New Set<Id>();
    
        For(SLA_History__c SLAH : Trigger.New)
        {
            caseIds.Add(SLAH.Case__c);
            System.debug('+++++++++++++caseIds:'+caseIds);
        }
    
        List<Case> caselist = [Select Id,OwnerId,Owner.Name,Owner_User_Role__c from CASE where id =: caseIds];
        System.debug('+++++++++++++caselist:'+caselist);
    
        For(SLA_History__c SLAH : Trigger.New)
        {    
            For(Case cas : caselist)
            {
                System.debug('+++++++++++++SLAH.Case__c:'+SLAH.Case__c);
                System.debug('+++++++++++++cas.ID:'+cas.ID);
                
                IF(SLAH.Case__c == cas.ID)
                {
                    System.debug('+++++++++++++cas.OwnerId:'+cas.OwnerId);
                    IF(cas.OwnerId != NULL)
                    {
                        SLAH.Case_Queue_Owner_Name__c = cas.Owner.Name ;
                        System.debug('+++++++++++++SLAH.Case_Queue_Owner_Name__c:'+SLAH.Case_Queue_Owner_Name__c);
                        IF(cas.Owner_User_Role__c!=null && cas.Owner_User_Role__c !='')
                            SLAH.Current_Support_Group__c = cas.Owner_User_Role__c;
                            System.debug('+++++++++++++SLAH.Current_Support_Group__c:'+SLAH.Current_Support_Group__c);
                        
                        SLAH.End_Time__c = null;
                        System.debug('+++++++++++++SLAH.End_Time__c:'+SLAH.End_Time__c);
                    }
                }
            }
        }    
    }
    
    IF(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)){
        system.debug('+++++++before insert and before update+++++');
        BusinessHours BH = [SELECT Id FROM BusinessHours WHERE Name = 'US Hub' LIMIT 1];

        For (SLA_History__c SH : Trigger.new) {
            IF ((SH.End_Time__c != NULL) && (BH != NULL)) {
                SH.ElapsedTimeInMins__c = BusinessHours.diff (BH.Id, SH.Start_Time__c, SH.End_Time__c) / 1000 / 60 ;
                SH.Number_of_Business_Hours__c = SH.ElapsedTimeInMins__c / 60 ;
                system.debug('++++40+++++SH.Number_of_Business_Hours__c:'+SH.Number_of_Business_Hours__c);
            }
        }
    }
}

 
I have implemented "liveAgent:clientChatQueuePosition" tag in a customized chat window to show the user at what place he is in Queue. When the request has been sent to the agent, however, the value is null. Do anyone let me know how when the queue position is zero another conditional message is displayed?
<tr>
 <td>
  <p style="font-size: 14px;">You are now being connected to an agent. Currently your position in the queue is <liveAgent:clientChatQueuePosition /></p>
 </td>                                               
 </tr>