Results 1 to 3 of 3

Thread: Dropdowns using Soap

  1. #1
    anztenney is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    18

    Default Dropdowns using Soap

    Is there a way to get dropdown entries that appear in the "Dropdown Editor" via SOAP? For example, I want to get all the possible values for the lead source select field using soap.

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Dropdowns using Soap

    anztenney,

    I've sent in a patch to allow you to do that but it hasn't been accepted I guess.

    This is what I had to do to get that to work:

    Added the following code to soap/SoapPortalUsers.php (you may need to add it to soap/SoapSugarUsers.php and just call it get_dom_list): (The language is hard coded here but you could easily get the system default or if using SoapSugarUsers get the current user's language.)
    PHP Code:
    /** [IC] eggsurplus: be able to retrieve dom list values */
    $server->register(
        
    'portal_get_dom_list',
        array(
    'session'=>'xsd:string''dom_name'=>'xsd:string'),
        array(
    'return'=>'tns:get_dom_list_result'),
        
    $NAMESPACE);

    function 
    portal_get_dom_list($session$dom_name){
        global 
    $app_list_strings;
        
    $app_list_strings return_app_list_strings_language('en_us'); // <-- This needs to be dynamic

        
    $error = new SoapError();
        if(! 
    portal_validate_authenticated($session)){
            
    $error->set_error('invalid_session');
            return array(
    'dom_name'=>$dom_name'name_value_list'=>array(), 'error'=>$error->get_soap_array());
        }

        
    $options_dom = array();
        
    $options_ret = array();
        
        
    $options_dom $app_list_strings[$dom_name]; //i.e. get 'case_status_dom'

        
    if(!is_array($options_dom)) {
            
    $error->set_error('no_dom_found');
            return array(
    'dom_name'=>$dom_name'name_value_list'=>array(), 'error'=>$error->get_soap_array());
        }

        foreach(
    $options_dom as $key=>$oneOption) {
            
    $options_ret[] = get_name_value($key,$oneOption);
        }
        return array(
    'dom_name'=>$dom_name'name_value_list'=>$options_ret'error'=>$error->get_soap_array());


    And add to soap\SoapTypes.php:
    PHP Code:
    /** [IC] eggsurplus: to retrieve dom lists */
    $server->wsdl->addComplexType(
            
    'get_dom_list_result',
            
    'complexType',
            
    'struct',
            
    'all',
            
    '',
        array(
            
    'dom_name'=>array('name'=>'dom_name''type'=>'xsd:string'),
            
    'name_value_list'=>array('name'=>'name_value_list''type'=>'tns:name_value_list'),
            
    'error' => array('name' =>'error''type'=>'tns:error_value'),
        )
    );
    /** END - [IC] */ 

  3. #3
    anztenney is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    18

    Default Re: Dropdowns using Soap

    I actually found a simpler way to get the dropdown values I wanted. If you want the values from the Dropdown Editor, then your code may be the correct thing, but here is what I did.

    Code:
    $result = $soapclient->call('get_module_fields',array('session'=>$session,'module_name'=>'Prospects'));
    foreach($result['module_fields'] AS $key=>$value){
            foreach($value['options'] AS $opNum=>$option){
              $return[$option['name']] = $option['value'];
          }
        }

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. nusoap vs. soap: which to use and why?
    By hanmari in forum General Discussion
    Replies: 6
    Last Post: 2008-05-12, 05:20 PM
  3. SOAP login() - Invalid Username/Password.
    By linzhixua34 in forum Developer Help
    Replies: 3
    Last Post: 2008-04-27, 08:17 PM
  4. SOAP Performance Issue Loading Accounts
    By artisticlight in forum General Discussion
    Replies: 1
    Last Post: 2007-07-20, 01:39 PM
  5. SOAP and Applescript?
    By mattjones99 in forum Developer Help
    Replies: 5
    Last Post: 2006-02-08, 08:00 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
  •