I am trying to create a Case creation form along with drag n drop file attachment to the case.

Case creation happens using Action of command button and what I want is if there is any attachment that needs to be processed using Remoting (drag n drop), then it should get the Case id just inserted.

So is there any way I can create the case get Id on VF page, pass it to VF remoting where I can attach the file to the case.??

Thanks in advance. Ray

1 Answer 1


Oncomplete attribute on action function allows us to call a javascript function on action complete

Best example is in Jeff blog on how to do this


I have tweaked this for your case so that it allows you to call javascript remoting after you obtain parent Id

<apex:page controller="ActionFunctionDemoController">  
 <apex:sectionHeader title="Action Function Demo" 
subtitle="Save a New Record"/>

 <apex:form >

  <apex:outputPanel id="jspanel"> 
  function onControllerReturn() {
   // This remoting call will use the page's timeout value
    function handleResult(result, event) { ... }

 <apex:actionFunction name="doControllerSave" action="{!save}" 

 <apex:pageBlock id="blockSection">

 <apex:pageBlockButtons >
   <apex:commandButton onclick="doControllerSave();" 
  oncomplete="onControllerReturn()" value="Save"/>
<apex:pageMessages />

 <apex:pageBlockSection columns="1">
   <apex:inputField value="{!cat.name}"/>  
   <apex:inputField value="{!cat.Cat2__c}"/>  


 Submit the form to successfully create a record. To generate an error, 
  remove the value for 'Cat2' and save.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .