You need to sign in to do that
Don't have an account?
ryepes15
Visualforce page not returning correct page
Contract Object
Fulfillment Object (custom object)
When an opportunity gets closed won, a contract gets created via a button.
What i want is the a fulfillment record to also create automatically when the contract gets created
i also what the end screen to be the edit screen of the contract that was created
What i have so far: In my FinalConfg sandbox i have the following:
Custom Button on the opportunity: Create Contract
Visual Workflow:Called: "Auto Create Fulfillment"
Visualforce Page called: "CreateContract"
Visualforce Class called: "OpportunityFlowControl"
Everything seems to work fine except for the end screen, it does not return me to the edit screen of the Contract
Here is the code to my class:
public class OpportunityFlowControl {
private final opportunity oppty;
private final contract contract;
public OpportunityFlowControl(ApexPages.StandardController stdController) {
this.oppty = (Opportunity)stdController.getRecord();
}
Boolean testmode = Test.isRunningTest();
//Calls referenced Flow below
public Flow.Interview.Auto_Create_Fulfillment flAutoCreate { get; set; }
//Gets Id of variables below from flow
public String getopptyID() {
if (flAutoCreate==null || ( testmode == true )){
return '';
}else{
System.Debug('OpptyID:' + flAutoCreate.OpptyID);
return flAutoCreate.OpptyID; //need test
}
}
public String getcontractID() {
if (flAutoCreate==null || ( testmode == true )) {
return '';
} else {
System.Debug('ContractId:' + flAutoCreate.ContractCreate);
return flAutoCreate.ContractCreate; //need test
}
}
//Used for Flow finish location
public PageReference getFinishPage(){
if (flAutoCreate==null || ( testmode == true )) { return new PageReference('');}
// need test case
if(flAutoCreate.ContractCreate == null || ( testmode == true )){
Contract cont;
cont = [Select ID,Name,ContractNumber, createdDate from Contract where Opportunity__c =: this.oppty.Id Order by createdDate desc Limit 1];
PageReference p = new PageReference('/' + cont + '/e');
p.setRedirect(true);
system.debug('Page Contract: ' + p);
return p;
}else {
/* PageReference p = new PageReference('/' + getopptyID());
p.setRedirect(true);
system.debug('Page Opportunity: ' + p);
return p; */
Contract cont;
cont = [Select ID,Name,ContractNumber, createdDate from Contract where Opportunity__c =: this.oppty.Id Order by createdDate desc Limit 1];
PageReference p = new PageReference('/' + cont + '/e');
p.setRedirect(true);
system.debug('Page Contract: ' + p);
return p;
}
}
}
Fulfillment Object (custom object)
When an opportunity gets closed won, a contract gets created via a button.
What i want is the a fulfillment record to also create automatically when the contract gets created
i also what the end screen to be the edit screen of the contract that was created
What i have so far: In my FinalConfg sandbox i have the following:
Custom Button on the opportunity: Create Contract
Visual Workflow:Called: "Auto Create Fulfillment"
Visualforce Page called: "CreateContract"
Visualforce Class called: "OpportunityFlowControl"
Everything seems to work fine except for the end screen, it does not return me to the edit screen of the Contract
Here is the code to my class:
public class OpportunityFlowControl {
private final opportunity oppty;
private final contract contract;
public OpportunityFlowControl(ApexPages.StandardController stdController) {
this.oppty = (Opportunity)stdController.getRecord();
}
Boolean testmode = Test.isRunningTest();
//Calls referenced Flow below
public Flow.Interview.Auto_Create_Fulfillment flAutoCreate { get; set; }
//Gets Id of variables below from flow
public String getopptyID() {
if (flAutoCreate==null || ( testmode == true )){
return '';
}else{
System.Debug('OpptyID:' + flAutoCreate.OpptyID);
return flAutoCreate.OpptyID; //need test
}
}
public String getcontractID() {
if (flAutoCreate==null || ( testmode == true )) {
return '';
} else {
System.Debug('ContractId:' + flAutoCreate.ContractCreate);
return flAutoCreate.ContractCreate; //need test
}
}
//Used for Flow finish location
public PageReference getFinishPage(){
if (flAutoCreate==null || ( testmode == true )) { return new PageReference('');}
// need test case
if(flAutoCreate.ContractCreate == null || ( testmode == true )){
Contract cont;
cont = [Select ID,Name,ContractNumber, createdDate from Contract where Opportunity__c =: this.oppty.Id Order by createdDate desc Limit 1];
PageReference p = new PageReference('/' + cont + '/e');
p.setRedirect(true);
system.debug('Page Contract: ' + p);
return p;
}else {
/* PageReference p = new PageReference('/' + getopptyID());
p.setRedirect(true);
system.debug('Page Opportunity: ' + p);
return p; */
Contract cont;
cont = [Select ID,Name,ContractNumber, createdDate from Contract where Opportunity__c =: this.oppty.Id Order by createdDate desc Limit 1];
PageReference p = new PageReference('/' + cont + '/e');
p.setRedirect(true);
system.debug('Page Contract: ' + p);
return p;
}
}
}
https://help.salesforce.com/HTViewHelpDoc?id=vpm_admin_onfinish.htm&language=en_US