cancel
Showing results for 
Search instead for 
Did you mean: 

UME user search with multiple search fields (AND / OR search)

Former Member
0 Kudos

Hi,

I'm struggling with a UME user search problem. I have multiple search fields: lastname, firstname, department

Searching in this fields is working with the default IPrincipalSearchFilter.SEARCHMETHOD_AND (default)

<a href="http://help.sap.com/javadocs/NW04/current/um/com/sap/security/api/IPrincipalSearchFilter.html#setSearchMethod(int)">JavaDocs SearchMethod_AND</a>

Now I would like to add an additional search field for searching in telephone, cellphone as well. BUT searching for a phone number with searching for one of the other fields should not be a AND search. Is this possible?

Here is the actual non-working code:


	Vector retVector = new Vector();

	//get Userdata with IUserFactory
	//////////////////////////////////////////////////////
	IResourceFactory resourceFactory = ResourceFactory.getInstance();
	IURLGeneratorService urlGen = (IURLGeneratorService)resourceFactory.getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);

	IUserFactory userFac = UMFactory.getUserFactory();				
	IUserSearchFilter srcFilter = null;		
	
	try
	{
		srcFilter = userFac.getUserSearchFilter();
	} catch (UMException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	if(lastName.length() > 0)
		srcFilter.setLastName(lastName + "*",ISearchAttribute.LIKE_OPERATOR, false);
	if(firstName.length() > 0)
		srcFilter.setFirstName(firstName + "*",ISearchAttribute.LIKE_OPERATOR, false);
	if(department.length() > 0)
		srcFilter.setDepartment(department + "*", ISearchAttribute.LIKE_OPERATOR, false);

			
//Here I need help!!!!!!! Please advice!!!
	if(telephone.length() > 0)
	{
		srcFilter.setTelephone("*" + telephone, ISearchAttribute.LIKE_OPERATOR, false);
		srcFilter.setCellPhone("*" + telephone, ISearchAttribute.LIKE_OPERATOR, false);
	}
	//if(mobil.length() > 0)
	//	srcFilter.setCellPhone("*" + mobil, ISearchAttribute.LIKE_OPERATOR, false);

	//Set maxium value for Result and thus limit the static variable SIZE_LIMIT_EXCEEDED
	//This method can only be used, if only one search attribute is specified -> thanks SAP
	if(srcFilter.getElementSize() <= 1)
		srcFilter.setMaxSearchResultSize(300);

	ISearchResult srcResult = null;
	try
	{
		srcResult = userFac.searchUsers(srcFilter);
	} catch (UMException e1) 
	{
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}

Thanks for any help...

Stefan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

I could still need some help. Is there no one who could give me a tip? Could I explain my problem clearly enough or do you need some more information about my problem?

Or is the search topic with searchFilter not a very common used thing?

Is there a possibility to do a search in the received search result? Can anyone explain how this would work?

Any ideas are welcome.

Regards,

Stefan

Former Member
0 Kudos

I think the API does not support this, you can not have nested filters with different search methods (AND / OR).

As a workaround, you might want to run multiple searches and combine the result yourself.

Former Member
0 Kudos

Could you give me a hint how I can run multiple searches and combine the results?

Thanks in advance.

Stefan

Answers (0)