Jump to content


Photo

Searching for Email Address using API Advanced Search

API

  • Please log in to reply
1 reply to this topic

#1 jimf

jimf

    Advanced Member

  • Members
  • PipPipPip
  • 64 posts

Posted 03 October 2012 - 01:51 AM

I've been setting up a wild-card search with the API. I want my user to be able to enter a search string and I would search across several fields for the data. The ability to do an OR search using the new Advanced Search was great, but I could not figure out how to determine how to search on email (since it was not a normal field). I got it working with the following code.

$searchParams = array(
     'dynamicSearch' => array(
	   'dynamicClauses' => array(
		 '0' => array(
		   'attributeIndexOrDerivedType' => 'name',
		   'structurePosition' => 1,
		   'firstName' =>  "$v"
		 ),
		 '1' => array(
		   'attributeIndexOrDerivedType' => 'name',
		   'structurePosition' => 2,
		   'lastName' =>  "$v"
		 ),
		 '2' => array(
		   'attributeIndexOrDerivedType' => 'name',
		   'structurePosition' => 3,
		   'mobilePhone' => "$v"
		 ),
		 '3' => array(
		   'attributeIndexOrDerivedType' => 'primaryEmail',
		   'structurePosition' => 4,
		   'primaryEmail' => array('emailAddress' => '$v')
		 ),
	   ),
	   'dynamicStructure' =>  '1 OR 2 OR 3 OR 4'
   
	 ),
	 'sort' => 'lastName.asc',
   );

since $v holds the search value. Jim will be found in firstname, lastname, email, or phone.

#2 raysto

raysto

    Zurmo Team

  • Administrators
  • 839 posts

Posted 03 October 2012 - 02:52 PM

Thanks for the tip Jim. Much appreciated!

Ray Stoeckicht
Zurmo Team
Try Zurmo Pro






Also tagged with one or more of these keywords: API

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users