Skip to main content
Good day, 

We have a call center application integrated with Salesforce. This application requires that a "disposition" be chosen when completing a phone call. Once the disposition is selected, a task record is added in which the Call Result value is set to the value of the disposition. 

Because users are able to disposition a call without ever actually opening the lead edit page, I would like to be able to redirect the user to a custom visual force page when a particular disposition is selected so that additional information can be gathered regarding that call. 

Flow/Process Builder does not appear to be an option so I believe that I need to go the route of creating an extension to the Lead controller. I would like the custom VF page to fire once a task record is saved with that call result and need to be able to pull the leadid from that task record as a part of the redirect to the VF page. 

Is a controller extension the the correct approach or is there a better method of accomplishing this? 

 
1 Antwort
  1. 12. Aug. 2019, 20:53
    Good afternoon everyone, I'm hoping that someone can advise whether I am on the right course here and/or offer any suggestions. Here is what I have done to try to accomplish this. 

    I created an after insert trigger on Task as shown here which calls an Apex class. Please note that i intend to do some additional validation of the WhatID and CallDisposition but have not added that yet: 

     

    trigger RefundTaskSubmitted on Task (after insert)

    {

    List<Task> TaskValues = new List<Task>();

    for (Task tsk: trigger.new)

    {

    String v_TaskID = Trigger.newMap.Get(tsk.ID).ID;

    Task TaskData = [SELECT Id, WhoID, WhatID, CallDisposition FROM Task WHERE Id IN :Trigger.new];

    if(TaskData.WhatID ==null)

    {

    String v_LeadID = TaskData.WhoID;

    vf_LeadEdit.LoadRefundPage(v_LeadID);

    }

    else {

    }

    }

    }

     The vf_LeadEdit class is shown here which calls the visual force page : 

     

    public class vf_LeadEdit

    {

    public final Lead ld;

    public vf_LeadEdit(ApexPages.StandardController stdController)

    {

    this.ld = (Lead)stdController.getRecord();

    }

    public static PageReference LoadRefundPage(string LeadID)

    {

    PageReference myVFPage = new PageReference('/apex/vf_LeadRefund');

    myVFPage.getParameters().put('ID', LeadID);

    myVFPage.setRedirect(true);

    return myVFPage;

    }

    }

    The VisualForce page code is shown as follows:

     

    <apex:page standardController="Lead" extensions="vf_LeadEdit">

    <apex:form >

    <apex:tabPanel >

    <apex:tab label="Enter Call/Refund Information" labelWidth="200">

    <apex:PageBlock >

    <apex:pageblocksection columns="1">

    <b><font color="red">Instructions:</font></b> Instructions.

    </apex:pageblocksection>

    <apex:pageblocksection columns="1">

    Additional Instructions

    </apex:pageblocksection>

    <apex:pageblocksection columns="1">

    <b>First Name:</b> {!Lead.FirstName} <br/>

    <b>Last Name:</b> {!Lead.LastName} <br/>

    <b>Lead Source:</b> {!Lead.LeadSource} <br/>

    <br/>

    <apex:inputField value="{!Lead.Status}" label="Selected Status"/>

    <apex:inputField value="{!Lead.Refund_Reason__c}" label="Reason Category"/> <br/>

    <apex:inputField value="{!Lead.Borrower_Goals__c}" label="Reason Details" style="width: 280px; height: 80px"/> <br/>

    <apex:inputField value="{!Lead.OwnerId}"/> <br/>

    </apex:pageblocksection>

    <div align="left" draggable="false">

    <apex:commandButton action="{!save}" value="Save"/>

    </div>

    </apex:PageBlock>

    </apex:tab>

    </apex:tabPanel>

    </apex:form>

    </apex:page>

    I had added some debug messages and found that the URL appears to be generating correctly. However, when a task is added, the redirect does not seem to fire and I'm left at the lead detail page. 

    Please note that my end goal here is to only have this fire when a specific value exists in the CallDisposition field of the task record, and when the WhatID value of that task record is null. Thanks in advance for any feedback. 
0/9000