Results 1 to 6 of 6

Thread: How to create a bug remotely (without logging in)

  1. #1
    LucasAtAmieStreet is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default How to create a bug remotely (without logging in)

    Hello All,

    We've just set up our first Sugar installation over at Amie Street and its been really useful so far. One of the things we'd like to do is setup a form on our site so that our members can file bug reports straight into Sugar. I've tried playing with some of the PHP code, but nothing successful as of yet, in terms of the system allowing users to create new bugs without having to login to sugar. Does anyone know of or used in the past of a script that will act as the catcher's mitt for the form data, through sugarforge or some other source? Is there something buried away in the documentation I haven't been able to find yet that will let us do this easily? Any info or suggestions is greatly appreciated.

    Best,
    Lucas

  2. #2
    jimatbes is offline Sugar Community Member
    Join Date
    Sep 2005
    Posts
    19

    Default Re: How to create a bug remotely (without logging in)

    Same question as http://www.sugarcrm.com/forums/showthread.php?t=14783.

    I saw some stuff on web services in the forums, but haven't come across any documentation or good examples yet.

  3. #3
    LucasAtAmieStreet is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default Re: How to create a bug remotely (without logging in)

    Thanks Jim! Hadn't even thought to try SOAP (where's that smack in the forehead emoticon?).

    In the examples DIR, there's a couple example SOAP interactions. SoapTestPortal2.php in particular uses the set_entry call, which is used to update or insert (as specified in the SOAP Overview ) to insert a new Lead entry. Lines 65-66 of SoapTestPortal2.php :

    PHP Code:
    echo '<br><br><b>CREATE LEAD:</b><BR>';
    $result $soapclient->call('portal_set_entry',array('session'=>$session 'module_name'=>'Leads''name_value_list'=>array(array('name'=>'first_name''value'=>'Test'), array('name'=>'last_name''value'=>'Lead'),  array('name'=>'portal_name''value'=>'portal_name'),  array('name'=>'portal_app''value'=>'SoapTestPortal'), array('name'=>'description''value'=>'A lead created through webservices')))); 
    I'll try out some code in the morning using the above geared for creating a new bug via a form and post it here when its ready for public consumption.

    Thanks Again!

    Lucas

  4. #4
    jimatbes is offline Sugar Community Member
    Join Date
    Sep 2005
    Posts
    19

    Default Re: How to create a bug remotely (without logging in)

    Ahh... the examples directory! I forgot about that!

    Thanks, Lucas! (And for the pointer to the overview.)

  5. #5
    LucasAtAmieStreet is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default Re: How to create a bug remotely (without logging in)

    Jim,

    Couldn't wait until the morning to jump on this. After some inspecting, there's no functionality right now in the soap server file to accomodate creating bugs. Really strange that its not there. So I'll have to do a rewrite of the file to register the func create_bug, essentially just the contents of modules/Bugs/Save.php, and register it with the server. More in a few hours.

    Best,
    Lucas

  6. #6
    LucasAtAmieStreet is offline Junior Member
    Join Date
    Aug 2006
    Posts
    4

    Default Re: How to create a bug remotely (without logging in)

    Ok here is the neccessary cahnges to the soap server file (NOT TESTED). Defines the function create_bug and registers it with the server:

    PHP Code:
    $server->register(
        
    'create_bug',
        array(
    'user_name'=>'xsd:string',
              
    'password'=>'xsd:string',
              
    'assigned_user_name'=>'xsd:string',
              
    'priority'=>'xsd:string',
              
    'status'=>'xsd:string',
              
    'type'=>'xsd:string',
              
    'source'=>'xsd:string',
              
    'category'=>'xsd:string',
              
    'found_in_release_name'=>'xsd:string',
              
    'name'=>'xsd:string',
              
    'description'=>'xsd:string',
              
    'work_log'=>'xsd:string'
              
    ),
        array(
    'return'=>'xsd:string'),
        
    $NAMESPACE);
    function 
    create_bug($user_name$password$assigned_user_name$priority$status$type$source$category$found_in_release_name$name$description$work_log)
    {
        if(!
    validate_user($user_name$password)){
            return 
    0;
        }
        
    $seed_user = new User();
        
    $user_id $seed_user->retrieve_user_id($user_name);
        
        
    $assigned_user = new User();
        
    $assigned_user_id $assigned_user->retrieve_user_id($assigned_user_name);
        
    // Bug class
        
    require_once('modules/Bugs/Bug.php');
        
    $oBug = new Bug();
        
        
    $oBug->retrieve('');
        if(!
    $oBug->ACLAccess('Save')){
                return -
    1;
        }
        if(empty(
    $status)){
            
    $status "New";
        }
        if(empty(
    $priority)){
            
    $priority "Medium";
        }
        if(empty(
    $source)){
            
    $source "Web";
        }
        if(empty(
    $category)){
            
    $category "Bug Tracker";
        }
        if(empty(
    $type)){
            
    $type "Defect";
        }
        
    $oBug->assigned_user_id   $assigned_user_id;
        
    $oBug->assigned_user_name $assigned_user_name;
        
    $oBug->name               $name;
        
    $oBug->priority           $priority;
        
    $oBug->description        $description;
        
    $oBug->work_log           $work_log;
        
    $oBug->release_name       $found_in_release_name;
        
    $oBug->source             $source;
        
    $oBug->product_category   $category;
        
    $oBug->type               $type;
        
    $oBug->status             $status;
        
    $oBug->save();
        
    $return_id $oBug->id;
        return 
    $return_id;

    More in the morning. Hopefully with a working example.

    Best,
    Lucas

Thread Information

Users Browsing this Thread

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

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
  •