cancel
Showing results for 
Search instead for 
Did you mean: 

Searching with several fields on the same Table with MDM COM API

Former Member
0 Kudos

Hi,

I'm using the MDM COM API and I have the following issue:

I want to make a search on the Products table based in the following conditions:

All Products which "Description" has the keyword = "Car" and Material Group = "2"

I have found that the following can narrow the search but only with one field at a time, but can't find how to make the quey with both fields (Material Group and Description):

rsd.Table = "Products"

rsd.Fields.Append("Material Number")

rsd.Fields.Append("Description")

rsd.Fields.Append("Material Type")

rsd.Fields.Append("Material Group")

rsd.Fields.Append("Base Unit")

searchTable = "Products"

displayField = "Description"

displayField2 = "Material Type"

searchString = "Car"

searchString2 = "2"

s.SearchTable = rsd.Table

s.Parameters.NewFreeFormParameter(searchTable).Fields.New(displayField).FreeForm.NewString(searchString, FreeFormSearchTypeEnum.xcPrefixSearchType)

's.Parameters.NewFreeFormParameter(searchTable).Fields.New(displayField2).FreeForm.NewString(searchString2, FreeFormSearchTypeEnum.xcEqualToSearchType)

' s.Parameters.NewLookupParameter()

rs = Catalogo.GetResultSet(s, rsd, "Material Number", True, 0)

Any advice is welcome

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Elias,

See the following <a href="/people/andreas.seifried/blog/2006/03/26/performing-free-form-searches-with-mdm-java-api which describes how to perform free-form searches via the Java API. The COM API works almost identically, so you should have no trouble implementing it in COM.

Walter

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Elias,

add the following line

search.SearchType() = SearchCombinationTypeEnum.xcGlobalAndSearchCombinationType

Hope this helps,

Richard

Former Member
0 Kudos

Hi Richard,

Ok but what should I do next? How to specify the two fields values and conditions?

Can you provide more code

Thanks in advance

Former Member
0 Kudos

Hi Elias,

You must uncomment the second statement shown below so that both parameters are added to the search. And by adding the line of code i gave you previously, the code will search for records having both search criteria.

s.Parameters.NewFreeFormParameter(searchTable).Fields.New(displayField).FreeForm.NewString(searchString, FreeFormSearchTypeEnum.xcPrefixSearchType)

's.Parameters.NewFreeFormParameter(searchTable).Fields.New(displayField2).FreeForm.NewString(searchString2, FreeFormSearchTypeEnum.xcEqualToSearchType)

Former Member
0 Kudos

Richard,

When the debuger gets to the second line:

s.Parameters.NewFreeFormParameter(searchTable).Fields.New(displayField2).FreeForm.NewString(searchString2, FreeFormSearchTypeEnum.xcEqualToSearchType)

The following error occurs:

An unhandled exception of type 'System.ArgumentException' occurred in MDM COM 1.exe

Additional information: The parameter is incorrect.

Any idea?

Former Member
0 Kudos

Hi Elias,

This is some vb code that worked for me. I call NewFreeFormParameter only once.

Dim ffParam As FreeFormTableParameter = search.Parameters.NewFreeFormParameter(Table)

ffParam.Fields.New(Field1).FreeForm.NewString(searchString1, FreeFormSearchTypeEnum.xcEqualToSearchType)

ffParam.Fields.New(Field2).FreeForm.NewString(searchString2, FreeFormSearchTypeEnum.xcSubstringSearchType)

Let me know if this works.

Richard

Former Member
0 Kudos

Thanks to All