2

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

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

http://blog.jeffdouglas.com/2011/01/17/passing-values-to-javascript-from-apex-controller-method/

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"> 
 <script>  
  function onControllerReturn() {
   alert('{!Id}');
   // This remoting call will use the page's timeout value
    Visualforce.remoting.Manager.invokeAction(
        '{!$RemoteAction.AccountRemoter.getAccount}',
        Id, 
        handleResult
    );
    function handleResult(result, event) { ... }
 }
 </script>
 </apex:outputPanel>

 <apex:actionFunction name="doControllerSave" action="{!save}" 
rerender="jspanel"/>

 <apex:pageBlock id="blockSection">

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


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

 </apex:pageBlock>
 </apex:form>

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

 </apex:page>  

You must log in to answer this question.

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