Results 1 to 6 of 6

Thread: need SOAP set_relationship help

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

    Default need SOAP set_relationship help

    Hi Again,

    I'm using Sugar 5.1a, and SOAP on php, mysql, apache.

    I have my custom module deployed, and visible in the tabs. I'm trying to relate it to an opportunity. I've set up a 1:1 Relationship CustomMod:Opp, and a 1:M Opp:CustomMod since each record in the custom mod can only relate to 1 opportunity, but each opportunity will have many records related to it from the CustomMod. I think this might be where my problem is occuring.

    Here is the code I used for set_relationship SOAP call:

    Code:
    $user_guid = $soapclient->call('get_user_id',$session_id);
    	
    $set_rel_params = array('session' => $session_id,
    						  'set_relationship_value' => array(
    								'module1'=> 'Opportunities',
    								'module1_id'=> '630d340b-092a-4f26-3bea-48fce873741b',
    								'module2' => 'capa_Applicant',
    								'module2_id'=> 'ec0aee7a-7b8b-cb76-b75e-490f71084079'));
    
    $result = $soapclient->call('set_relationship',$set_rel_params);
    echo $result;
    Echoing the $result just prints "Array". I've tried echoing $result['error_value'], $result[0] (to get the first index on the array and nothing shows up. Also, nothing shows up in my sugarcrm.log file for errors or anything.

    If someone could shed light on what I'm doing wrong, it would be greatly appreciated.

  2. #2
    saloob is offline Member
    Join Date
    Apr 2008
    Posts
    9

    Default Re: need SOAP set_relationship help

    I know this is pretty late in the game, but try using var_dump($result); to get a quick lookof the guts of the return values..you can maybe see what the probs are if any.

    BTW - did you work out how to do it?

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

    Default Re: need SOAP set_relationship help

    No, I never did get it working. I abandoned and moved on to another issue!

    And now I'm having even more problems with SOAP login getting rejected from a 5.2 instance. Once I get the login rejection issue resolved, I'm going to go back and see if I can get the set_relationship function to work..

    Thank you for your reply! I got frustrated with the lack of response on the forums, so I abandoned them for a while. It seems no one else has these kinds of issues with the SOAP API...

    Thanks again!
    Darcy

  4. #4
    saloob is offline Member
    Join Date
    Apr 2008
    Posts
    9

    Default Re: need SOAP set_relationship help

    Darcy, try this;

    Not sure how good my coding is, but I noticed getting a time-out after leaving for a while, so set a 15 minute check to log in. This means that within 15 minutes, you can use the same id captured in a session. I thought it also better than creating a new session each time the app connected to do something...

    Below that I put the code to make a relationship.

    Note: $soapclient->decodeUTF8(false); deals with multi-byte charcters and allows being returned as UTF-8 because SugarCRM for some reason send it as ASCII - which turns into "mojibake" with Japanese.

    PHP Code:
    # Start Here
    ##############################################
    #  Setting SOAP Access

    function do_stuff ($api_user$api_pass$crm_wsdl_url$action$params){

      
    // Set up session with timeout check

      
    $sugar_sessioner $_SESSION["sugarsoapsessionid"];
      
    $date date("Y-m-d G:i:s");

      
    $auth_array = array( 'user_auth' => array ('user_name' => $api_user,
                           
    'password' => md5($api_pass),
                            )
                         );

      require_once (
    "nusoap/nusoap.php");

      
    $soapclient = new nusoap_client$crm_wsdl_urltrue );

      
    $soapclient->decodeUTF8(false);

      if (
    $sugar_sessioner == NULL){

         
    $login_results $soapclient->call('login',$auth_array);
         
    $sugar_session_id $login_results['id'];
         
    $sugar_sessioner $sugar_session_id."[]".$date;
         
    $_SESSION["sugarsoapsessionid"] = $sugar_sessioner;

         } else {
    //    echo "SESSIONER: ".$sugar_sessioner."<BR>";
         // Session will expire - give ourselves time limit of say 15 mins
         
    $thisminutes date("i");

         list(
    $sugar_session_id,$createdtime) = explode('[]',$sugar_sessioner);
         
    // Must check session timeout
         
    if ($createdtime == NULL){
            
    $checktime 100;
            } else {
            list (
    $datep1$datep2) = explode (" "$createdtime);
            list (
    $hours$minutes$seconds) = explode (":"$datep2);
            
    $checktime $minutes+15;
            if (
    $checktime>60){
               
    $checktime $checktime-60;
               }
            } 
    // end if not null

         
    if (($checktime>($thisminutes+14)) || (($thisminutes-16)<$checktime)){

            
    $login_results $soapclient->call('login',$auth_array);
            
    $sugar_session_id $login_results['id'];
            
    $sugar_sessioner $sugar_session_id."[]".$date;
            
    $_SESSION["sugarsoapsessionid"] = $sugar_sessioner;

            } else {
        
    // All sweet
            
    list($sugar_session_id$createdtime) = explode('[]',$sugar_sessioner);
    //    echo "SESS: ".$sugar_session_id."<BR>";
            
    }

         } 
    // end if has session

    # End setting SOAP Access
    ##############################################
    # Relate IDs in two Modules

    switch ($action){

     case 
    'relatemymodules':

        
    $set_rel_params = array(
                  
    'session' => $sugar_session_id,
                  
    'set_relationship_value'=>array(
                                
    'module1'=> $params[0],
                                
    'module1_id'=> $params[1],
                                
    'module2' => $params[2],
                                
    'module2_id'=> $params[3]
                                )
                            );

         
    // Now Add the Product
         
    $returnpack $soapclient->call('set_relationship',$set_rel_params); 

      break;
     } 
    // end switch

    // end function

    # EndRelate IDs in two Modules
    ##############################################
    # Set up the params to send to this;

    $api_user "admin";
    $api_pass "mypass";
    $crm_wsdl_url "http://www.mydonain.com/sugar/soap.php?wsdl";

    $params[0] = "Accounts";
    $params[1] = "92e05b85-4526-c287-cc2d-496efd9f0b18";
    $params[2] = "Contacts";
    $params[3] = "64f06b83-4234-e456-df6q-867ewe3f1t98";
    $action "relatemymodules";

    $returned do_stuff ($api_user$api_pass$crm_wsdl_url$action$params);

    var_dump ($returned);

    # End app
    ############################################### 
    I think that should work...good luck!

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

    Default Re: need SOAP set_relationship help

    Thank you kindly for your reply. I appreciate the help! However, I have to solve the problem currently of my new configuration not accepting soap requests. When I call the soap test, instead of giving me the string I send it, its replying with:

    bool(false)

    talk about cryptic! Off to search some more...
    Last edited by darcy.rippon; 2009-01-16 at 02:30 PM. Reason: Corrected the response from the soap server.

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

    Default Re: need SOAP set_relationship help

    The solution is posted on this thread:
    http://www.sugarcrm.com/forums/showthread.php?t=42976

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SOAP login() - Invalid Username/Password.
    By dsandor in forum Developer Help
    Replies: 12
    Last Post: 2010-12-07, 09:13 AM
  2. SugarCRM, SOAP and Fonality ... the fun continues...
    By sprunka in forum Developer Help
    Replies: 10
    Last Post: 2009-04-17, 10:06 PM
  3. nusoap vs. soap: which to use and why?
    By hanmari in forum General Discussion
    Replies: 6
    Last Post: 2008-05-12, 05:20 PM
  4. SOAP login() - Invalid Username/Password.
    By linzhixua34 in forum Developer Help
    Replies: 3
    Last Post: 2008-04-27, 08:17 PM
  5. SOAP Performance Issue Loading Accounts
    By artisticlight in forum General Discussion
    Replies: 1
    Last Post: 2007-07-20, 01:39 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
  •