• Larry Caper II 7
  • NEWBIE
  • 10 Points
  • Member since 2016
  • Independent Salesforce Administrator
  • Streamlined CRM


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
I would like to display a related list from a custom object on my Case record. Please reference the information below:
  • Case Object: Contains a lookup field (Listing__c)
  • Listing Object: Master in a master-detail relationship with an object called Booking Rule(BookingRule__c)
  • Booking Rule Record: Due to the master-detial relationship, every Booking Rule record is associated to a Listing
Big Idea: The Case object and Booking Rule object are unrelated. However, they are somewhat related due to the Listing lookup field on the Case record. I would like to display the Booking Rules related list from my custom object (Listing__c) page layout on my Case page layout.

I hear a visualforce page will do the job. However, I'm unsure where to start, what APEX code to use and how to bring it all together.
Thanks in advance for anyone willing to help me out!
Does anyone have any idea as to why my OnClick Javascript button will work in every browser except IE. I receive an error saying: "A problem with the OnClick Javascript for this button or link was encountered: Expected ')' "

The code is below:
 
if("{!Lead.DT_App_Fee_Paid__c }" == '' || "{!Lead.Enrollment_Agreement_Signed__c }" == ''){ 
alert("REMINDER: Please populate the following field(s): App Fee Paid and Enrollment Agreement Paid") 
} 

else {window.open('/a0M/e?retURL={!Lead.Id}&Name={!Lead.Name}&00N1500000Fu4CN={!Lead.Phone}&00N1500000Fu4DB={!Lead.Email}&00N1500000Fu4Dz={!Lead.Enrollment_Agreement_Signed__c}&00N1500000Fu4DL={!Lead.LeadSource}&00N1500000Fu4C8=Enrolled&00N1500000Fu4DQ={!Lead.Program_Recruit_c__c}&00N1500000Fu4Df={!Lead.DT_App_Submitted__c}&00N1500000Fu4Dk={!Lead.DT_App_Fee_Paid__c}&CF00N1500000FuCSY={!Lead.DT_First_Contacted_User__c}&00N1500000FuCSd={!Lead.DT_First_Contacted__c}&00N1500000FuCSi={!Lead.DT_Tour_Booked__c}&00N1500000FuCSn={!Lead.Date_of_Tour__c}&CF00N1500000FuCSs={!Lead.DT_Tour_Complete_User__c}&00N1500000FuCSx={!Lead.DT_Tour_Complete__c}&00N1500000FuCT2={!Lead.FA_Appt_Date__c}&CF00N1500000FuCT7={!Lead.DT_FA_Appointment_Complete_User__c}&CF00N1500000FuCUF={!Lead.DT_App_Fee_Paid_User__c}&00N1500000HCbao={!Lead.Street}&00N1500000HCbat={!Lead.City}&00N1500000HCd3m={!Lead.State}&00N1500000HCbo7={!Lead.PostalCode}&00N1500000HCbb8={!Lead.Country}'); 

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
var c = new sforce.SObject("Lead"); 
c.id = "{!Lead.Id}"; 
c.Status = "Enrolled"; 
result = sforce.connection.update([c]); 
window.location.reload(); 
}

 
Please help, I have 50% coverage for the trigger below. However, I am receiving the following error and nor do I know if I'm writing the correct test class: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, RollupEnrollmentCount: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.RollupEnrollmentCount: line 43, column 1: []
_____________________________

trigger RollupEnrollmentCount on DJEnrollment__c (after insert, after update, after delete) {

     Set<Id> CampaignIds = new Set<Id>();
   
   if(Trigger.isDelete) {
     for(DJEnrollment__c test:Trigger.Old) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
    }   
   
   }
   else
   if(Trigger.isUpdate) {

     for(DJEnrollment__c test:Trigger.New) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }

     for(DJEnrollment__c test:Trigger.Old) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }   
   
   }
   else
   {
     for(DJEnrollment__c test:Trigger.New) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }
   }

    AggregateResult[] groupedResults = [SELECT count(id)enrollmentCount, EnrollClass_Name__c FROM DJEnrollment__c WHERE EnrollClass_Name__c in :CampaignIds GROUP BY EnrollClass_Name__c];
    
    Map<id,Campaign> campaignMap = new Map<Id,Campaign>([SELECT id, Class_Total_Enrollments__c FROM Campaign WHERE Id in :CampaignIds]); 
    
    for(AggregateResult ar: groupedResults) {
          campaignMap.get((Id)ar.get('EnrollClass_Name__c')).Class_Total_Enrollments__c = (decimal) ar.get('enrollmentcount');
    }
    
    try {
        update campaignMap.values();
    }   catch(DmlException e) {
        System.debug(e.getMessage());
    }

}
I would like to display a related list from a custom object on my Case record. Please reference the information below:
  • Case Object: Contains a lookup field (Listing__c)
  • Listing Object: Master in a master-detail relationship with an object called Booking Rule(BookingRule__c)
  • Booking Rule Record: Due to the master-detial relationship, every Booking Rule record is associated to a Listing
Big Idea: The Case object and Booking Rule object are unrelated. However, they are somewhat related due to the Listing lookup field on the Case record. I would like to display the Booking Rules related list from my custom object (Listing__c) page layout on my Case page layout.

I hear a visualforce page will do the job. However, I'm unsure where to start, what APEX code to use and how to bring it all together.
Thanks in advance for anyone willing to help me out!
Please help, I have 50% coverage for the trigger below. However, I am receiving the following error and nor do I know if I'm writing the correct test class: 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, RollupEnrollmentCount: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.RollupEnrollmentCount: line 43, column 1: []
_____________________________

trigger RollupEnrollmentCount on DJEnrollment__c (after insert, after update, after delete) {

     Set<Id> CampaignIds = new Set<Id>();
   
   if(Trigger.isDelete) {
     for(DJEnrollment__c test:Trigger.Old) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
    }   
   
   }
   else
   if(Trigger.isUpdate) {

     for(DJEnrollment__c test:Trigger.New) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }

     for(DJEnrollment__c test:Trigger.Old) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }   
   
   }
   else
   {
     for(DJEnrollment__c test:Trigger.New) {
      
        CampaignIds.add(test.EnrollClass_Name__c);   
    
     }
   }

    AggregateResult[] groupedResults = [SELECT count(id)enrollmentCount, EnrollClass_Name__c FROM DJEnrollment__c WHERE EnrollClass_Name__c in :CampaignIds GROUP BY EnrollClass_Name__c];
    
    Map<id,Campaign> campaignMap = new Map<Id,Campaign>([SELECT id, Class_Total_Enrollments__c FROM Campaign WHERE Id in :CampaignIds]); 
    
    for(AggregateResult ar: groupedResults) {
          campaignMap.get((Id)ar.get('EnrollClass_Name__c')).Class_Total_Enrollments__c = (decimal) ar.get('enrollmentcount');
    }
    
    try {
        update campaignMap.values();
    }   catch(DmlException e) {
        System.debug(e.getMessage());
    }

}

We have implemented the live Agent functionality in Production. We have also our portal users for whome this chat functionality provided. Through portal home page , clients can initiate chat (chat button provided on portal). Also we have implemented the Prechat form in order to receive the data like Name, email, Account..

 

This is working fine but clients needs to fill out these details in Prechat form, which is not feasible since they are Portla users. So I am prepopulating these details like name, email in Pre chat form. Used prety simple code at VF (mentioned below) , this is working fine in Salesforce preview. However, when used on Portal , prechat form is not reflecting the correct Name , email in Pre chat form. In the name field this is reflecting Sitename and in email email this is using the by default site user email id.

 

We want when, every client logged in Portal and initiating the chat , in prechat form , Client name and email should be in user context....

 

Please let me know any workaround / solution how to resolve this.

 

I will really appreciate this ....

 

<apex:page showHeader="false" standardController="User" >

    <script>
        function clickBtn()
        {
            var btnSubmit = document.getElementById('prechat_submit');
            btnSubmit.click();
        }
    </script>

    <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form -->
    <script type="text/javascript">
        (function()
        {
            function handlePageLoad()
            {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
                document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1]));
            }
            if (window.addEventListener)
            {
                window.addEventListener('load', handlePageLoad, false);
            }
            else
            {
                window.attachEvent('onload', handlePageLoad, false);
            }
        })();
    </script>
   
    <h1>Pre-chat Form</h1>
    <form method='post' id='prechatForm'>
   
        <style type="text/css">
            body {
                margin: 0 auto;
                padding: 0;
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
                font-size: 12px;
                color: #737373;
                line-height: 16px;
            }                   

            p {
                font-weight: bolder
            }
           
            td {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }
           
            h1 {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }

            .btnClass {
                font-family: 'Trebuchet MS', Helvetica, sans-serif;
            }

        </style>

        <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field -->   
        <table border="0" width="400px">
            <tr>
                <td>
                    <b>Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' />          
                </td>
            </tr>
            <tr>
                <td>
                    <b>Email Address: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' />
                </td>
            </tr>
            <tr>
                <td>
                    <b>Property Name: </b>
                </td>
                <td>
                    <input type='text' size="40" name='liveagent.prechat:Account' value='{!getAccountName}' />
                </td>
            </tr>
            <tr>
                <td>
                   
                </td>
                <td align="center">
                    <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" />
                </td>
            </tr>
        </table>

        <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" />        

    </form>


</apex:page>

 

Thanks alot !!!!