Results 1 to 9 of 9

Thread: Code for retrieving Lead

  1. #1
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Code for retrieving Lead

    Hello,

    i need to retrieve a lead from its id, using the PHP Lead class. Here's what I've done so far :

    content of test.php :
    PHP Code:
    <?php

    if(!defined('sugarEntry'))define('sugarEntry'true);

    require_once(
    'include/entryPoint.php');
    require_once 
    'modules/Leads/Lead.php';

    $lead = new Lead();
    $lead->retrieve($_GET["leadid"]);
    echo 
    'retrieving '.$_GET["leadid"].'<br>';
    foreach (
    $lead as $a => $b)
            echo(
    $a." : ".$b."<br>");
    ?>
    and using this URL :

    https://mysugarcrm/test.php?leadid=260549b3-4cdc-4097-4199-4e5e2a510e42

    with 2605[...]10e42 being the record id I want to retrieve, which I can find in a SugarCRM URL like this :

    https://mysugarcrm/index.php?module=Leads&[...]&record=260549b3-4cdc-4097-4199-4e5e2a510e42

    This code doesn't work, I get this :

    Code:
    retrieveing 260549b3-4cdc-4097-4199-4e5e2a510e42
    field_name_map : Array
    id :
    date_entered :
    [...]
    all the fields being empty.

    Can someone tell me what I did wrong ?

    By the way, can someone point me to the API documentation ? sugardev.net being down, I couldn't find another resource, and the developer guide available at sugarcrm.com doesn't help...

    thanks !

  2. #2
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    Nobody can help me ?

  3. #3
    eitrix's Avatar
    eitrix is offline Sugar Community Member
    Join Date
    Aug 2010
    Location
    Serbia
    Posts
    396

    Default Re: Code for retrieving Lead

    it should be:
    $lead = $lead->retrieve($_GET["leadid"]);

    since retrieve return an object you want
    CRM Software Engineer
    Eontek - www.eontek.rs

  4. #4
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    Thanks for your reply. I found in modules/Leads.php the following code int the converted_lead function :
    PHP Code:
    $lead = new Lead();
    $lead->retrieve($leadid);
    $lead->status='Converted';
    $lead->save(); 
    which is why I thought my code was correct.

    Though I still can't make it work. Here is what I have now :
    PHP Code:
    <?php
    if(!defined('sugarEntry'))define('sugarEntry'true);

    require_once(
    'include/entryPoint.php');
    require_once 
    'modules/Leads/Lead.php';

    $lead = new Lead();
    $lead=$lead->retrieve($_GET["leadid"]);
    echo 
    'retrieveing '.$_GET["leadid"].'<br>';
    var_dump($lead);
    ?>
    which displays :
    retrieveing 260549b3-4cdc-4097-4199-4e5e2a510e42
    NULL


    Could it be that the leadid value is wrong ? I use the value that can be found in the record parameter in standard SugarCRM URLs.

    Thanks again for your help !

  5. #5
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    Can't somebody help me ? Too bad...

  6. #6
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    come on people, I need this ! doesn't someone have a hint of what's wrong with my code ?

  7. #7
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    Last attempt. can't someone help me ? Maybe it's a security issue. Isn't it required to identify before using the API ?

  8. #8
    citapinc is offline Sugar Community Member
    Join Date
    Sep 2011
    Location
    Anaheim, CA
    Posts
    81

    Default Re: Code for retrieving Lead

    Ben:

    I'm not a PHP programmer (well, not yet), but I did notice something odd. Look at your require_once statements. On the top statement you have the values surrounded with () while the second one does not. Will that make a difference?

    Also do you need to pad the leadid with spaces or remove spaces to make it a fixed size so it can find the record?

    Just some thoughts...

  9. #9
    Benjamin C. B. is offline Sugar Community Member
    Join Date
    Jul 2011
    Posts
    39

    Default Re: Code for retrieving Lead

    thanks for your reply
    I don't think require_once needs parenthesis. I tried adding them, though, and it didn"t change anything.
    About padding the id, I don't see why it should be needed, since it's exatly the same size as standard id in the database...

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. SOAP code for retrieving contacts
    By ikmnet in forum Developer Help
    Replies: 4
    Last Post: 2009-10-08, 08:22 PM
  2. Error Retrieving lead list
    By cyberitpros in forum Help
    Replies: 7
    Last Post: 2008-02-06, 09:09 AM
  3. retrieving related beans in php code
    By bogo123 in forum Help
    Replies: 2
    Last Post: 2008-01-18, 12:18 PM
  4. Error Retrieving Lead List.
    By kenlohwh in forum Help
    Replies: 1
    Last Post: 2007-04-11, 01:52 PM
  5. Error Retrieving Lead List
    By csaling in forum Help
    Replies: 2
    Last Post: 2005-11-18, 01:30 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
  •