Results 1 to 9 of 9

Thread: SOAP V2 get_relationships sample?

  1. #1
    ikmnet is offline Member
    Join Date
    Sep 2009
    Location
    San Jose, CA
    Posts
    8

    Default SOAP V2 get_relationships sample?

    We recently upgraded to SOAP V2, in Java, and are having trouble with the get_relanships call

    What we are trying to do is find all contacts fo a given account given a certain first and last name. The code we have is


    String condition = " contacts.first_name = '" + StringUtil.replace(firstName,"'", "''") + "'"
    + " and contacts.last_name = '" + StringUtil.replace(lastName,"'", "''") + "'";

    Get_entry_result_version2 contactList = port.get_relationships(
    sessionID,
    "Accounts",
    accountId,
    "Contacts",
    condition,
    new String[] {"id"},
    new Link_name_to_fields_array[] { },
    0);
    Entry_value[] contactIds = contactList.getEntry_list();


    But it never returns any entries in contactList.getEntry_list(). Could not find any samples or documentation so can anyone shed light on this one?

    regards,

    Joop Kaashoek

  2. #2
    ikmnet is offline Member
    Join Date
    Sep 2009
    Location
    San Jose, CA
    Posts
    8

    Smile Re: SOAP V2 get_relationships sample?

    Found the problem, the related field should not be "Contacts" but "contacts", so the following call works

    Get_entry_result_version2 contactList = port.get_relationships(
    sessionID,
    "Accounts",
    accountId,
    "contacts",
    condition,
    new String[] {"id"},
    new Link_name_to_fields_array [] { },
    0);
    Entry_value[] contactIds = contactList.getEntry_list();

    This is different from the V1 call, so be careful!

  3. #3
    anat is offline Member
    Join Date
    Aug 2010
    Location
    Adelaide, South Australia, Australia
    Posts
    11

    Default Re: SOAP V2 get_relationships sample?

    Hi ikmnet,
    I'm trying to get a list of the newsletters that a Lead (or Contact) is subscribed to.

    I'm trying :


    Code:
    $SugarSoap_v2->getRelationships() function is running :
    $session : f3793a0d9a66c94f8a7568ebe3f92f61,
    $module_id : '71f0eb9a-c70d-70fb-20f0-4c84d47fbf13',
    $module_name : 'Leads',
    $related_fields : Array();
    $link_field_name : 'ProspectLists',
    $related_module_link_name_to_fields_array : Array ();
    $deleted : 0,
    
    
    get_relationships() results contains :
    Array(
    [entry_list] => Array()
    [relationship_list] => Array()
    The code above is my debugging output.
    I'm using the http://crm.<domain>.com/service/v2/soap.php?wsdl service using SugarCRM Community Edition Version 5.5.2 (Build 1224).

    I've triple checked that the lead is subscribed to one list and I also unsubscribed them from a different one, yet I can't get any results back.
    I've tried about 10 different variations on the above, but as I've never seen a proper explanation of how to make the calls or more than your example I've been unable to work it out.
    I was up till 11:30pm last night banging my head against the wall trying to work this out, so if anyone can help it'd be greatly appreciated.
    I have a 99% working version of my script using the v1 SOAP API, however it doesn't let me delete relationships, so I'm unable to re-subscribe previously unsubscribed users.

    Cheers!
    Michael Kubler | Technology Officer

    Australian Network for Art and Technology [ANAT]
    e: anat@anat.org.au | ph: +61 8 8231 9037

    www.anat.org.au | www.filter.org.au | www.synapse.net.au
    Twitter: __ANAT | Facebook: http://bit.ly/bF9fXl

    The Australian Network for Art and Technology (ANAT) is supported by the Visual Arts and Craft Strategy, an initiative of the Australian, State and Territory Governments; the Australian Government through the Australia Council, its arts funding and advisory body, and the South Australian Government through Arts SA.

  4. #4
    anat is offline Member
    Join Date
    Aug 2010
    Location
    Adelaide, South Australia, Australia
    Posts
    11

    Wink Re: SOAP V2 get_relationships sample?

    PS : I'm using PHP, but the issue I'm having is the complete lack of documentation regarding the SOAP API.
    Apart from logging in to the version 1 SOAP API there's basically no Sugar tutorials or documentation of any actual use.

    I've read https://code.sugarcrm.com/viewvc/pub...?view=annotate
    and the WDSL, and the forums. But the v2 queries have never been properly explained.
    Diagrams, or multiple decent examples would be great!
    </end rant>
    Michael Kubler | Technology Officer

    Australian Network for Art and Technology [ANAT]
    e: anat@anat.org.au | ph: +61 8 8231 9037

    www.anat.org.au | www.filter.org.au | www.synapse.net.au
    Twitter: __ANAT | Facebook: http://bit.ly/bF9fXl

    The Australian Network for Art and Technology (ANAT) is supported by the Visual Arts and Craft Strategy, an initiative of the Australian, State and Territory Governments; the Australian Government through the Australia Council, its arts funding and advisory body, and the South Australian Government through Arts SA.

  5. #5
    anat is offline Member
    Join Date
    Aug 2010
    Location
    Adelaide, South Australia, Australia
    Posts
    11

    Default Re: SOAP V2 get_relationships sample?

    AH HA!!!
    I found it!

    What I couldn't understand was where you can get a listing of the LInked fields. Turns out it's listed as a link_fields array when you run a get_module_fields SOAP call on the requested module.

    I've extended my custom Module -> Fields listing function to also output a list of Linked fields for each module.


    As an example for the Leads Module :

    Leads fields
    1. id
    2. name
    3. date_entered
    4. date_modified
    5. modified_user_id
    6. modified_by_name
    7. created_by
    8. created_by_name
    9. description
    10. deleted
    11. assigned_user_id
    12. assigned_user_name
    13. salutation - Mr., Ms., Mrs., Dr., Prof.
    14. first_name
    15. last_name
    16. full_name
    17. title
    18. department
    19. do_not_call
    20. phone_home
    21. phone_mobile
    22. phone_work
    23. phone_other
    24. phone_fax
    25. email1
    26. email2
    27. invalid_email
    28. email_opt_out
    29. primary_address_street
    30. primary_address_street_2
    31. primary_address_street_3
    32. primary_address_city
    33. primary_address_state
    34. primary_address_postalcode
    35. primary_address_country
    36. alt_address_street
    37. alt_address_street_2
    38. alt_address_street_3
    39. alt_address_city
    40. alt_address_state
    41. alt_address_postalcode
    42. alt_address_country
    43. assistant
    44. assistant_phone
    45. converted
    46. refered_by
    47. lead_source - Cold Call, Existing Customer, Self Generated, Employee, Partner, Public Relations, Direct Mail, Conference, Trade Show, Web Site, Word of mouth, Email, Campaign, Other
    48. lead_source_description
    49. status - New, Assigned, In Process, Converted, Recycled, Dead
    50. status_description
    51. reports_to_id
    52. report_to_name
    53. account_name
    54. account_description
    55. contact_id
    56. account_id
    57. opportunity_id
    58. opportunity_name
    59. opportunity_amount
    60. campaign_id
    61. campaign_name
    62. c_accept_status_fields
    63. m_accept_status_fields
    64. accept_status_id
    65. accept_status_name - accept, decline, tentative, none
    66. webtolead_email1
    67. webtolead_email2
    68. webtolead_email_opt_out
    69. webtolead_invalid_email
    70. birthdate
    71. portal_name
    72. portal_app

    == Linked Fields ==
    This is the bit that's interesting.

    created_by_link
    * [name] -> 'created_by_link'
    * [type] -> 'link'
    * [relationship] -> 'leads_created_by'
    * [module] -> 'Users'
    * [bean_name] -> 'User'


    modified_user_link
    * [name] -> 'modified_user_link'
    * [type] -> 'link'
    * [relationship] -> 'leads_modified_user'
    * [module] -> 'Users'
    * [bean_name] -> 'User'


    assigned_user_link
    * [name] -> 'assigned_user_link'
    * [type] -> 'link'
    * [relationship] -> 'leads_assigned_user'
    * [module] -> 'Users'
    * [bean_name] -> 'User'


    email_addresses_primary
    * [name] -> 'email_addresses_primary'
    * [type] -> 'link'
    * [relationship] -> 'leads_email_addresses_primary'
    * [module] -> ''
    * [bean_name] -> ''


    email_addresses
    * [name] -> 'email_addresses'
    * [type] -> 'link'
    * [relationship] -> 'leads_email_addresses'
    * [module] -> ''
    * [bean_name] -> ''


    reports_to_link
    * [name] -> 'reports_to_link'
    * [type] -> 'link'
    * [relationship] -> 'lead_direct_reports'
    * [module] -> ''
    * [bean_name] -> ''


    accounts
    * [name] -> 'accounts'
    * [type] -> 'link'
    * [relationship] -> 'account_leads'
    * [module] -> ''
    * [bean_name] -> ''


    campaign_leads
    * [name] -> 'campaign_leads'
    * [type] -> 'link'
    * [relationship] -> 'campaign_leads'
    * [module] -> ''
    * [bean_name] -> ''


    tasks
    * [name] -> 'tasks'
    * [type] -> 'link'
    * [relationship] -> 'lead_tasks'
    * [module] -> ''
    * [bean_name] -> ''


    notes
    * [name] -> 'notes'
    * [type] -> 'link'
    * [relationship] -> 'lead_notes'
    * [module] -> ''
    * [bean_name] -> ''


    meetings
    * [name] -> 'meetings'
    * [type] -> 'link'
    * [relationship] -> 'meetings_leads'
    * [module] -> ''
    * [bean_name] -> ''


    calls
    * [name] -> 'calls'
    * [type] -> 'link'
    * [relationship] -> 'calls_leads'
    * [module] -> ''
    * [bean_name] -> ''


    oldmeetings
    * [name] -> 'oldmeetings'
    * [type] -> 'link'
    * [relationship] -> 'lead_meetings'
    * [module] -> ''
    * [bean_name] -> ''


    oldcalls
    * [name] -> 'oldcalls'
    * [type] -> 'link'
    * [relationship] -> 'lead_calls'
    * [module] -> ''
    * [bean_name] -> ''


    emails
    * [name] -> 'emails'
    * [type] -> 'link'
    * [relationship] -> 'emails_leads_rel'
    * [module] -> ''
    * [bean_name] -> ''


    campaigns
    * [name] -> 'campaigns'
    * [type] -> 'link'
    * [relationship] -> 'lead_campaign_log'
    * [module] -> 'CampaignLog'
    * [bean_name] -> 'CampaignLog'


    prospect_lists
    * [name] -> 'prospect_lists'
    * [type] -> 'link'
    * [relationship] -> 'prospect_list_leads'
    * [module] -> 'ProspectLists'
    * [bean_name] -> ''

    A working example call to get a listing of all related Prospect Lists (newsletter subscriptions) is :

    $this->proxy->get_relationships
    (
    $session_id,
    $module_id = '71f0eb9a-c70d-70fb-20f0-4c84d47fbf13',
    $module_name = 'Leads',
    $related_fields = array();
    $link_field_name = 'prospect_lists',
    $related_module_link_name_to_fields_array = array();
    $deleted = '0',
    )
    Note, you should have the $session_id from the soap login and the $module_id() is the ID of the Lead you want to know about. The listing of prospect_lists id's can then help you work out what the person is subscribed to.
    Michael Kubler | Technology Officer

    Australian Network for Art and Technology [ANAT]
    e: anat@anat.org.au | ph: +61 8 8231 9037

    www.anat.org.au | www.filter.org.au | www.synapse.net.au
    Twitter: __ANAT | Facebook: http://bit.ly/bF9fXl

    The Australian Network for Art and Technology (ANAT) is supported by the Visual Arts and Craft Strategy, an initiative of the Australian, State and Territory Governments; the Australian Government through the Australia Council, its arts funding and advisory body, and the South Australian Government through Arts SA.

  6. #6
    jdbertron is offline Sugar Community Member
    Join Date
    May 2011
    Posts
    12

    Default Re: SOAP V2 get_relationships sample?

    Thanks a bunch for that little explanation. And shame on the developers for making the documentation useless in that regard.

  7. #7
    jdbertron is offline Sugar Community Member
    Join Date
    May 2011
    Posts
    12

    Default Re: SOAP V2 get_relationships sample?

    Now this may seem impossible but I use the SOAP set_entry and set_relationship successfully to create a record in one of my modules, which has a relationship with other modules.
    The problem is that although the calls are successful, and the proper records show up in the database:

    1- Sugar doesn't see the association.
    2- A query to get the entry list of parent records specifying the linkfield doesn't find the associated record.

    If however I create the record in Sugar, the query using the link field has no problem finding the association.
    This is puzzling since I can see the proper ida/idb record in the correlated tables in MySQL.
    I've tried repair as well.

    Doe anyone have any suggestion ?

    J.D.

  8. #8
    Sin OB is offline Junior Member
    Join Date
    Nov 2011
    Location
    Bristol
    Posts
    4

    Default Re: SOAP V2 get_relationships sample?

    Thank you so much anat. Your suggestion to use get_module_fields() helped me clear things up immensely.

  9. #9
    textlocal is offline Sugar Community Member
    Join Date
    Nov 2011
    Posts
    16

    Question Re: SOAP V2 get_relationships sample?

    Quote Originally Posted by jdbertron View Post
    Now this may seem impossible but I use the SOAP set_entry and set_relationship successfully to create a record in one of my modules, which has a relationship with other modules.
    The problem is that although the calls are successful, and the proper records show up in the database:

    1- Sugar doesn't see the association.
    2- A query to get the entry list of parent records specifying the linkfield doesn't find the associated record.

    If however I create the record in Sugar, the query using the link field has no problem finding the association.
    This is puzzling since I can see the proper ida/idb record in the correlated tables in MySQL.
    I've tried repair as well.

    Doe anyone have any suggestion ?

    J.D.
    Did you ever get anywhere with this? Having the same problem with the set_relationship....

    Thanks
    James

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 2010-11-04, 10:42 PM
  2. SOAP: Problem with get_relationships; Accounts and Project
    By murray.hopkins in forum Developer Help
    Replies: 1
    Last Post: 2008-08-22, 06:22 AM
  3. Replies: 0
    Last Post: 2008-07-22, 12:02 AM
  4. Replies: 1
    Last Post: 2008-06-23, 10:08 AM
  5. SOAP get_relationships usage?
    By jkwalnut in forum Developer Help
    Replies: 1
    Last Post: 2008-06-16, 11:05 PM

Tags for this Thread

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
  •