function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun ChopraVarun Chopra 

Attach file in flow only at a perticular screen

Hi

I have created  a visual force flow and I need to attach a file within the flow.
I know it is only possible by embedding the flow in the visual force page. But the thing is the attach file option is displaying in each screen of the flow. So If i attach file in the very first screen (When record is not creted yet from flow), then it will throw the parent Id missing error.

Is there any way to show File attachment option only at a perticular screen where we know record Id is not null.

Visual force Page code :
 
<apex:page controller="AttachFileInFlow"  >
 <flow:interview name="NewclientScreen1"  interview="{!myflow}">

</flow:interview>

<apex:form >

<apex:outputText value="Input File: "/><apex:inputFile value="{!attach.body}" filename="{!attach.name}"/><br/>
<apex:commandButton value="Upload" action="{!upload}"/>
</apex:form>

</apex:page>
Apex Class Code
 
public with sharing class AttachFileInFlow  {
 public String parentId {get;set;}
 public Attachment attach {get;set;}
 public String objectID {get;set;} 
 public Flow.Interview.NewclientScreen1 myflow{get;set;}
 


  public String getObjectID()
{

     if (myflow == null) { 
            system.debug('myflow.Insurance_Quote_Id ==== ??' + null );
            return null; 
      }
      else {
             objectID =myflow.Insurance_Quote_Id ;//myflow.objectId;
             system.debug('myflow.Insurance_Quote_Id ==== ??' +  objectID);
             return objectID;
     }
}
     
       public AttachFileInFlow(){
                attach = new Attachment();
                objectID = getObjectID();
        }
   
     public ApexPages.Pagereference upload(){
      
            if(myflow != null)
           {
                   system.debug('myflow.objectID ==== ??' +   objectID);
                   system.debug('myflow.objectID ==== ??' +   myflow.Insurance_Quote_Id);
                   Attachment a = attach.clone(false, true, false, false);
                   a.ParentId = myflow.Insurance_Quote_Id;
                   
                   attach.Body = null;
                    insert a;
             
              }
              return null;
          
     }
}

Please Help !

Thanks In Advance,


 
ShashankShashank (Salesforce Developers) 
How about conditionally rendering and rendering the inputfile tag? http://www.oyecode.com/2013/04/how-to-re-render-part-of-visualforce.html