AnsweredAssumed Answered

Relate to Lead by Parent_type not working when using SOAP api with a Custom Module

Question asked by Garrett Strauss on Oct 19, 2015

I am using Sugar Professional Version 6.5.21 (Build 1155)

I have created a new custom module with the Module Builder. 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 receive data pushed from a web form via the SOAP api and relate it to a specific Lead.

After multiple tests with the api, it is clear that it's not possible to associate the record to the Lead using the 'parent_type' and 'parent_id' fields as used to relate a Note to a Lead in the Core Modules with an api request.

I would like to find out what code I would need to add, so that a Custom Module can also be related to a Lead the same way a Core Module can. This would be helpful information for anyone doing development in SugarCRM using the SOAP API.

I have been wrestling with this problem for a month now, and I still can work out a fix. Any help would be really appreciated!


Code I have been trying to get to work so far (my custom module is called "APP_Applications". The file I am modifying is: /soap/SoapSugarUsers.php

* Attach a application to another bean. Once you have created a application to store an
* attachment, the application needs to be related to the bean.
* @param String $session -- Session ID returned by a previous call to login.
* @param String $application_id -- The ID of the application that you want to associate with a bean
* @param String $module_name -- The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method)..
* @param String $module_id -- The ID of the bean that you want to associate the application with
* @return no error for success, error for failure
function relate_application_to_module($session,$application_id, $module_name, $module_id){
    global $beanList, $beanFiles;
    $error = new SoapError();
        return $error->get_soap_array();
        return $error->get_soap_array();
    global $current_user;
    if(!check_modules_access($current_user, $module_name, 'read')){
        return $error->get_soap_array();
    $class_name = $beanList['applications'];
    $seed = new $class_name();
        return array('result_count'=>-1, 'entry_list'=>array(), 'error'=>$error->get_soap_array());

    if($module_name != 'Contacts'){
        $seed->parent_id = $module_id;





    return $error->get_soap_array();
    array('session'=>'xsd:string', 'module_name'=>'xsd:string', 'module_id'=>'xsd:string', 'select_fields'=>'tns:select_fields'),