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:
The vf_LeadEdit class is shown here which calls the visual force page :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 VisualForce page code is shown as follows: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;
}
}
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.<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>
1 Antwort