Jump to content


Photo

REST API - Multiselect Field help

rest api api multiselect

  • Please log in to reply
5 replies to this topic

#1 jamesGO3D

jamesGO3D

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 11 September 2014 - 06:24 PM

Trying to get Contacts if the multiselect custom field "groupSelect" contains the value. I have tried using 'equals' as well as 'oneOf' and cant seem to return any results. If i search by first name it works so it seems its just the 'relatedAttributeName' or something like that. PLEASE HELP! 

 

Or even better if anyone has figured out or knows how to get a User based on their Groups from the API that would fix all my problems as well. 

'search' => array(
    'modelClassName' => 'Contact',
    'searchAttributeData' => array(
      'clauses' => array(
          
          
         1 => array(
           'attributeName'        => 'groupSelect',
           'relatedAttributeName' => 'values',
  'operatorType'         => 'equals',
           'value'                => 'Prop Mgmt Leader',
  
         ),
      ),
      'structure' => '1',
    ),
  ),


#2 Ivica

Ivica

    Advanced Member

  • Moderators
  • 565 posts

Posted 16 September 2014 - 03:35 PM

I found issue, just replace groupSelect with groupSelectCstm(Cstm postfix is added to field names that are added via designer) and it should work fine(if you added this field via designer). If you added this field in code of Contact model, then your query should work fine.

 

Let me know if this helped.



#3 jamesGO3D

jamesGO3D

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 16 September 2014 - 04:00 PM

I actually did add the the field through the code. I assume the API search thought the contacts still uses the ContactSearchView or something like that? Do I need to add the field to a "ContactSearch" file since it is a custom field? 

I even just tried to do an API search through a regular drop-down field and it seems that its not finding that either. It seems that the attribute needs to be added to the contacts module somewhere if you could help me out that would be amazing



#4 Ivica

Ivica

    Advanced Member

  • Moderators
  • 565 posts

Posted 16 September 2014 - 07:45 PM

ok, in that case can you provide me code that you used in Contact model?

Also have you added it to view too?



#5 jamesGO3D

jamesGO3D

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 16 September 2014 - 07:52 PM

Contact.php 'relations': not sure if the 'NOT_OWNED' is it but the other 'OWNED' field wasnt working either

'groupSelect' => array(static::HAS_ONE, 'MultipleValuesCustomField', static::NOT_OWNED,
                    static::LINK_TYPE_SPECIFIC, 'groupSelect'),

Contact.php 'elements': ChecklistMultiSelectDropDown extends MultiSelectDropDown field that i created

 'groupSelect' => 'ChecklistMultiSelectDropDown',

Contact.php 'customFields'

            'groupSelect' => 'GroupSelects',

ContactEditAndDetailsView 

 array('cells' =>
     array(
       array(
         'elements' => array(
            array('attributeName' => 'groupSelect', 'type' => 'ChecklistMultiSelectDropDown'),
                        ),
                    ),
                                           
               ),
         ),


#6 jamesGO3D

jamesGO3D

    Advanced Member

  • Members
  • PipPipPip
  • 47 posts

Posted 17 September 2014 - 03:29 PM

Okay I have figured it out but I believe there is something still a bit off.

 

I used the exact same api call 

  
         1 => array(
           'attributeName'        => 'groupSelect',
           'relatedAttributeName' => 'values',
           'operatorType'         => 'equals',
           'value'                => 'Prop Mgmt Leader',
          ),
  

but had to add this search clause for the first name as well for the api return any results. without this firstName != "xyz" it doesnt work

 2 => array(
           'attributeName'        => 'firstName',
 	   'operatorType'         => 'doesNotEqual',
           'value'                => 'xyz',
		   
         ),

I would still like to know why this is necessary for the API to return results :) thank you Ivica!!

 







Also tagged with one or more of these keywords: rest api, api, multiselect

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users