• Ed Smith
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

I working with a flow that creates a custom object  Application. I have created a custom controller to control the VF page for the flow:interview, based on sample code. The controller also has code to create an upload button for uploading attachments to the Applicaiton from a second VF page that is set as the finishLocation.

 

The problem is that since the flow is finished, the variable myflow.vaApplicationId is null when I invoke the Upload page reference on the second VF page. I get a error. 

 

Big Question: How do I create a variable that will persist after the flow has finished? I'm new to programming, but really want to make this work.

 

 

 

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!upload}' in component <apex:page> in page docupload

 

 

Class.ApplicationPageController.upload: line 28, column 1

 

 

public class ApplicationPageController {

public Flow.Interview.Online_Application myFlow {get; set;}

public String getApplicationId() {
if (myFlow==null) return null;
else return myFlow.vaApplicationID;
}


public String getApplicationLink() {
if (myFlow==null) return null;
else return Page.docupload.geturl() + 'id=' + myFlow.vaApplicationID;
}


public Attachment attachment {
get {
if (attachment == null)
attachment = new Attachment();
return attachment;
}
set;
}

public PageReference upload() {

attachment.ParentID = myflow.vaApplicationId; // put it in application



try {
insert attachment;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
return null;
} finally {
attachment.body = null; // clears the viewstate
attachment = new Attachment();
}

ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
return null;
}
}

 

I have a dynamic radio button item list that displays the Names from the Contact object with a stored value of Id.

 

The next step retrieves the Contact detail based on the passed Id value and stored in variables.

 

The next step displays the detail screen where the Contact details are shown in textbox fields via variables.

 

This is working fine up to this point.

 

Now when I press the Previous button and select a different Contact from the radio button list. The detail screen is still displaying the first item that I have selected.

 

It seems that it's caching the the values from the first selection, is there anyway to resolve this? Thanks.

I built a Visual Flow process that assigns a value to a variable then uses this variable to lookup a Contact from the database. When I try to change the value after a match has been found by clicking the 'Previous' button, change the search input, click the 'Next' button, it still gives me the result of my first match. It seems that clicking the 'Next' button doesn't resubmit the form or there is a cache of some kind.

 

Does anybody have the same issue?