0

I am very new to visualforce (and flow incidentally), so I'm not sure what's going wrong. I've created a new flow to create a new case. I made a new Visualforce page for the flow so that I could make a button and have the end of the flow result in going to the newly created Case.

I am including my visualforce page and controller code below. In my flow, I added a screen after the case creation that simply states "Case Created", so that the page has time to pull the flow variable that contains the new page ID. Any help or hints as to what I'm doing wrong would be greatly appreciated!

VF Page:

<apex:page standardcontroller="Contact" extensions="ContactFlowExtension" showHeader="false"     sidebar="false">
    <flow:interview name="Ticket_Creation_Flow_2_0" interview="{!flDemo}" finishLocation="{!CID}">
    <apex:param name="ContactId" value="{!contId}"/>
    </flow:interview>
</apex:page>

Controller Extension:

public class ContactFlowExtension
{
    private final Contact cont;

    public ContactFlowExtension(ApexPages.StandardController stdController)
    {
        this.cont = (Contact)stdController.getRecord();
    }


    public Flow.Interview.Ticket_Creation_Flow_2_0 flDemo { get; set; }

    public String getmyID()
    {
        if (flDemo == null) return '';
        else return flDemo.CaseID;    
    }

    public PageReference getCID()
    {
        PageReference p = new PageReference(getmyID() + '/');
        p.setRedirect(true);
        return p;
    }

    public String getContId()
    {
        List<Contact> t = 
             [
            SELECT Id from contact
                WHERE id =: ApexPages.currentPage().getParameters().get('id') limit 1];

        String contID = null;    
        for (Contact str : t)
        {
            contID += str + ',';
        }
        contId = ContId.subString(0, contID.length());
        return contId;
    }
}

Edit: I forgot to include the error. I get this error once the flow completes and I click "Finish".

Invalid Page Redirection The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance.

1

Try this:

private String getmyId() 
{
        if (myId==null) return '';
        else{
            return myFlow.myID;     
        }           
    }

//Used for Flow finish location
public PageReference getFinishPage(){
    if(myFlow <> null){
        newID = myFlow.myId;
    }
    if(newID <> null){
        PageReference p = new PageReference('/' + newID );
        p.setRedirect(true);
        return p;
    }else{
        return null;
    }
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.