APIs, SDKs, and Services > XML-JSON for Process Central > Request Form Attachments

Request Form Attachments

In order to support attachments in process request forms, the following changes must be made to the form.
  1. 1. Find the input <form> tag and change it to specify POST as the method and multipart/form-data as the enctype.
  2. Change the following:

    <form id="DocumentInputForm$ID" name="DocumentInputForm$ID" action="">
    to use POST method and multipart/form-data enctype:

    <form id="DocumentInputForm$ID" name="DocumentInputForm$ID"
    action="" method="post" enctype="multipart/form-data">
    Note: This example shows form ID DocumentInputForm$ID. You should not change the form ID in your HTML file.
  3. 2. On the next line directly below the updated <form> tag, add the following hidden input fields:

  4. <input type="hidden" name="_json" value="" class="_json$ID" />
    <input type="hidden" name="responseContentType" value="text/html" />
    <input type="hidden" name="responseWrap" value="textarea" />
  5. 3. Add the HTML control for file upload within the HTML form. Here is an example:

  6. <input id="Document_attachment_1$ID" name="Document_attachment_1"
    value="" size="50" type="file" />
  7. 4. Move the submit button which currently is located outside of the <form> tags into the form so that it is before </form>.
  8. 5. Change the type of the submit button from type='button' to type='submit'.

  9. <input type="submit" id="sendRequest$ID" value="Send Request"
    class="avc_form_instance_save" />
  10. 6. Delete the following two lines of JavaScript from the documentReady function:

  11. // Assign handler for saving form data entered by the user
  12. 7. Add the following JavaScript to the documentReady function:

  13. $('#DocumentInputForm$ID').submit(function() {
    // Important always return false to prevent standard browser submit
    // and page navigation
    return false;
  14. 8. Replace the following JavaScript in the _submitRequest() function:

  15. AE_AJAX_SERVICE_UTIL.postJSON(url, request, _showResponseCallback,
    _showFaultCallback, _communicationErrorCallback);

    var jsonString = JSON.stringify(request);
    var options = {
    dataType : 'json',
    url: url,
    success: function(aJsonResponse) {
    $("#sendRequest$ID").attr("disabled", false);
    error: function(aXMLHttpRequest, aTextStatus, aErrorThrown) {
    $("#sendRequest$ID").attr("disabled", false);
    If you use this methodology (with the jQuery Forms plugin), the success callback function is used for success and for faults. Your code in the success callback function should examine the JSON result to determine if the response is a fault.