• pbraggS
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    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 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;
}
}