AnsweredAssumed Answered

File uploads in Custom Module (Document) not working via SOAP api

Question asked by Garrett Strauss on Sep 22, 2015
Latest reply on Oct 11, 2015 by Garrett Strauss
Hi,

I am using Sugar Professional Version 6.5.21 (Build 1155)

I have created a new custom module with the Module Builder based on the Documents sub module. I have successfully deployed the new module, and it has a Many-to-One relationship with Leads. The purpose of the custom module is to push data from a web form via the SOAP api which I am successfully using to create leads and notes with uploaded note attachments elsewhere between the website and sugarcrm.

My question is, is it possible to upload files via the SOAP api to a Custom Module in sugarcrm? And also, is it possible to associate the record to the Lead using the 'parent_type' and 'parent_id' fields in the Core Modules.

Screenshots:



All of my tests so far have failed to work. I'm stumped as to what to try next, so any help would be greatly appreciated.

This is some of the code I am using, that works with Core Modules:

  // Create a new Application, return the SOAP result
function createApplication($data)
  {
    // Parse the data and store it into a name/value list
    // which will then pe passed on to Sugar via SOAP
    $name_value_list = array();
    foreach($data as $key => $value)
      array_push($name_value_list, array('name' => $key, 'value' => $value));

    // Fire the set_entry call to the Applications module
    $result_application = $this->soap->call('set_entry', array(
      'session'         => $this->session,
      'module_name'     => 'APP_Applications',
      'name_value_list' => $name_value_list
    ));

    return $result_application;
  }

//create note for Application
$result = $sugar->createApplication(array(
  'document_name'           => "New Application",
  'parent_type'             => 'Leads',
  'parent_id'               => // Existing Sugar Lead ID
  'course_name'             => 'SIB50110',
  'course_intake'           => '2016',
  'application_status'      => 'Pending_Review',
  'filename'                => "Online Application - Student Name etc",
  'uploadfile'              => base64_encode(file_get_contents($attachment_path))
));


Thanks!
Garrett

Outcomes