CRM Open Source Business & Social CRM Software

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to access Custom module through SOAP

  1. #1
    sgandhi is offline Sugar Team Member
    Join Date
    Aug 2007
    Posts
    217

    Default How to access Custom module through SOAP

    Hi All,
    In module builder, you create a new package by giving a name of the package and a key which is alphnumeric key. Then you create a new module for this package by giving a name. So now this module name will be key_modulename.

    For Ex.
    Package name is "People" and key is "foo" and custom module name is "CustomPerson" then the actual module name will be "foo_CustomPerson" and that's the module name should be give to the SOAP funcitons like get_entry, get_entry_list and so on.

    I have tried some function like get_entry to access custom modules fields information and it does work but haven't tried all the function.

    set_relationship on custom module does not work and here is the fix for it.

    In handle_set_relationship of SoapSugarUsers.php, there is a line of code

    PHP Code:
    $key array_search(strtolower($module2),$mod->relationship_fields); 
    Replace this code with

    PHP Code:
                $key array_search(strtolower($module2),$mod->relationship_fields);
                if (!
    $key) {
                            require_once(
    'modules/Relationships/Relationship.php');
                            
    $key Relationship::retrieve_by_modules($module1$module2$GLOBALS['db']);
                            if (!empty(
    $key)) {
                                        
    $mod->load_relationship($key);
                                        
    $mod->$key->add($module2_id);
                                        return 
    $error->get_soap_array();
                            } 
    // if
                
    // if 
    -Samir
    Last edited by sgandhi; 2009-01-29 at 12:07 AM.

  2. #2
    darcy.rippon is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    121

    Default Re: How to access Custom module through SOAP

    THANK YOU! I appreciate your help on this issue...

  3. #3
    mcheatham is offline Member
    Join Date
    Jun 2008
    Posts
    5

    Default Re: How to access Custom module through SOAP

    I am not able to get the get_entry, get_entry_list or set_entry to work with a custom module. This module is visible on the sugar tabs and is returned in the list when I call get_available_modules.

    The error I get is
    {'description': 'This module is not available on this server', 'number': '20', 'name': 'Module Does Not Exist'}, 'field_list': [], 'entry_list': []}

    I am using CE 5.2.0a, and added the above code to the helper function

    Any ideas.

    Thanks

  4. #4
    Rudi Mentär is offline Senior Member
    Join Date
    Sep 2008
    Posts
    157

    Default Re: How to access Custom module through SOAP

    Hi, i have exactly the same problem, but this fix did not help. Any ideas why this could not work for me?

  5. #5
    jcorry is offline Senior Member
    Join Date
    Jun 2009
    Posts
    26

    Default Re: How to access Custom module through SOAP

    For Ex.
    Package name is "People" and key is "foo" and custom module name is "CustomPerson" then the actual module name will be "foo_CustomPerson" and that's the module name should be give to the SOAP funcitons like get_entry, get_entry_list and so on.

    I have tried some function like get_entry to access custom modules fields information and it does work but haven't tried all the function.
    So, get_entry_list() works when I call it on a custom module by simply passing it the module name...not key_ModuleName.

    I can call the API methods on this module this way.

    Except for set_relationship()...which throws no soap fault or other error...but simply doesn't set the relationship.

    I'm going nuts trying to figure this out...

  6. #6
    alecgonzales is offline Member
    Join Date
    Nov 2009
    Posts
    5

    Default Re: How to access Custom module through SOAP

    Quote Originally Posted by jcorry View Post
    So, get_entry_list() works when I call it on a custom module by simply passing it the module name...not key_ModuleName.

    I can call the API methods on this module this way.

    Except for set_relationship()...which throws no soap fault or other error...but simply doesn't set the relationship.

    I'm going nuts trying to figure this out...
    has anyone figured the set_relationship bug on custom modules?

  7. #7
    jkohlbach's Avatar
    jkohlbach is offline Senior Member
    Join Date
    Apr 2010
    Location
    Brisbane, Australia
    Posts
    103

    Default Re: How to access Custom module through SOAP

    *bump*

    Sorry for opening an old thread but has the issue of using set_relationship soap call on a custom module working or not?

    I'm attempting to add a relationship to "Cases" and my new module "Store"

    $result = $controller->soapClient->call(
    'set_relationship',
    array(
    'session' => $sessionID,
    'relate_array' => array(
    'module1' => 'Cases',
    'module1_id' => $newCaseID,
    'module2' => 'Store',
    'module2_id' => $storeID
    )
    )
    );

    Would love some assistance if anyone has a clue why this isn't working

    Thanks,
    Josh
    Last edited by jkohlbach; 2010-05-19 at 02:58 AM.

  8. #8
    jkohlbach's Avatar
    jkohlbach is offline Senior Member
    Join Date
    Apr 2010
    Location
    Brisbane, Australia
    Posts
    103

    Default Re: How to access Custom module through SOAP

    Just so this thread has an answer if someone finds it via the search engines as I did:

    Version: 5.5.2 CE

    My relationship was one to many. One Store to Many Cases. There's some issues surrounding this relationship creation in the module builder vs. the studio. Mine was created with the module builder and I had to recheck the relationships table to make sure it was there (weirdly it lists it as many to many and changes it back if you try to hack the DB).

    I also had the soap call backwards, Store should have been in module 1 and Cases in module 2. After that it worked a treat.

    So my soap calls now create the case putting the store's ID in the appropriate field on the cases module, then create the new relationship between the store and the new case using their IDs.

    Of course, make sure you quick repair and repair relationships.

  9. #9
    drock is offline Member
    Join Date
    Aug 2010
    Posts
    9

    Talking Re: How to access Custom module through SOAP

    Thanks for all these posts... I finally was successful building a relationship between Accounts and my custom module Sites via SOAP. Sugar CE 5.5.4 and nusoap latest.

    An Account can have many sites. A site belongs to one Account.

    1. In module builder, create (basic) module Sites and add a new relationship. Primary Module: Site, Rel: Many to One, Secondary Module: Accounts. Add this Accounts relationship to your Sites list view if you want.

    2. Deploy the module. Use Admin->Repair and run Quick Repair and Rebuild, then run Rebuild Relationships.

    3. Use your new module and create data via the Sugar UI to make sure it works as expected (Subpanel under Accounts called "Sites", etc.)

    4. Use soap to call get_available_modules to figure out the name of your custom module as far as the SOAP API is concerned

    5. Use soap to call get_module_fields with the name of your module from step 4. Look through the results at the link_fields array, and find your link type field for your relationship.

    For me this looked like:
    Code:
    [3] => Array
                    (
                        [name] => a9582_sites_accounts
                        [type] => link
                        [relationship] => a9582_sites_accounts
                        [module] => 
                        [bean_name] => 
                    )
    6. Make your normal soap set_entry call. Forget about setting the relationship in this call (the easy way, like setting account_id field when inserting a contact, which somehow automagically populates the relationship, will not work).

    7. Make a second soap call to method set_relationship. You must have the order correct for this call. For me, the call looks like:


    Code:
    		
    $set_relationship_params = array( 
    			'session' => $session,
    			'module_name' => 'a9582_sites', /* custom module, where the relationship was created, "primary module" */
    			'module_id' => $sugarID, /* id of site, get from set_entry call */
    			'link_field_name' => 'a9582_sites_accounts', /* the LINK field type name, from Step 5  */
    			'related_ids' => array($myAccountSugarID) /* id of Account you want to relate to */
    		);		
    		
    		$result = $client->call('set_relationship',$set_relationship_params); //nuSoap
    The only weird part is that there seem to be additional link fields for my custom module (like a9582_sites_accounts_1). I ignored these are used the most sensible and first one. These may be from hours of failed attempts.

  10. #10
    Join Date
    Jun 2010
    Posts
    10

    Default Re: How to access Custom module through SOAP

    Thanks drock for the useful tips
    Techstore for all your Website Design and Online Marketing needs

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 2010-11-29, 10:24 AM
  2. Replies: 11
    Last Post: 2010-08-07, 09:03 PM
  3. SOAP access to custom built module
    By thymeit in forum Help
    Replies: 1
    Last Post: 2008-05-14, 10:34 AM
  4. Replies: 6
    Last Post: 2008-04-17, 12:05 PM
  5. Access Control List - Custom Module
    By kgeving in forum Help
    Replies: 1
    Last Post: 2007-04-06, 03:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •