cancel
Showing results for 
Search instead for 
Did you mean: 

MDM4J Search Options

Former Member
0 Kudos

Hello

I would like to know the feasibility of the following requirement

When I search for a Product "NX-8" in the repository, I expect the the system to return all the product whose name matches "NX-8" and they should be aligned based on other field "Item Status".

For example, following are the products in repository

NX-8 - Active

NX-816 - InActive

NX-823 - Active

When I do search, I expect the following results in order

NX-8 - Active

NX-823 - Active

NX-816 - InActive

Basically, I want all the inactive products to be displayed at the last in the search results.

Please let me know if the above stuff is possible through MDM4J APIs.

As of now, here is my search code logic, just pick the products irrespective of 'item status'

Search search = new Search(ConfigProperties.getProduct_table());

FreeFormTableParameter fftpNames = search.GetParameters().NewFreeFormTableParameter(ConfigProperties.getProduct_table());

FreeFormParameterField ffpfName = fftpNames.GetFields().New("SKU");

ffpfName.GetFreeForm().NewString(searchValue, FreeFormParameter.SubstringSearchType);

A2iResultSet rs = catalogData.GetResultSet(search, rsd, "SKU", true, page);

Thanks

Prakash

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Neeharika

I was trying to locate the class "RetriveLimtedRecordsCommand" in MDM4J API document.

But, I could not find it. Is this a part of MDM4J or New Java5 APIS ?

Regards

Prakash

Former Member
0 Kudos

Hi Prakash,

Try this code as RetriveLimtedRecordsCommand is not available in 4J document.

String sortField = itemstatus;

boolean sortAscending = true;

int page = 0;

A2iResultSet rs =catalogData.GetResultSet(search, rsd, sortField, sortAscending, page);

Regards,

Neeharika

Former Member
0 Kudos

Hi Neeharika

The code what you have posted will sort records based on "itemstatus" only.

I need to sort the results base don two fields "SKU" and "Itemstatus" and the results sorted out as follows

NX-8 - Active

NX-823 - Active

NX-816 - InActive

Do you have any suggesstion for the above ?

Actually, I tried the following code

Search search = new Search(ConfigProperties.getProduct_table());

FreeFormTableParameter fftpNames = search.GetParameters().NewFreeFormTableParameter(ConfigProperties.getProduct_table());

FreeFormParameterField ffpfName = fftpNames.GetFields().New("SKU");

ffpfName.GetFreeForm().NewString(searchValue, FreeFormParameter.SubstringSearchType);

FreeFormParameterField ffpfName2 = fftpNames.GetFields().New("Item Status");

ffpfName2.GetFreeForm().NewString("e", FreeFormParameter.PostfixSearchType);

( Itemstatus values are 'Active', 'Inactive', 'Obsolete' )

A2iResultSet rs = catalogData.GetResultSet(search, rsd, "Item Status", true, page);

But the problem with above code is..

When I search for "NX-8" product,

NX-823 - Active

NX-8 - Active

NX-816 - InActive

'Nx-8' is not being displayed as first record, even though its the correct match.

In fact, in the actual results what I got, the NX-8 is not appearing in the first few pages of results

Regards

Prakash

Former Member
0 Kudos

Hi Prakash,

As per my knowledge, sorting cannot be done at a time on 2 fields.

This is because when records are sorted based on one field, and again sorting on the same result set but different field will result in the sorting of former field according to latter sort criteria.

Regards,

Neeharika

Former Member
0 Kudos

Thanks Minaz & Neeharika!

I will try out your suggesstions and update the thread.

Thanks

Prakash

Former Member
0 Kudos

Hi Prakash,

Records can be retrieved with required fields sorted by RetriveLimtedRecordsCommand.

Please refer to the method setFieldSortingOrder in RetriveLimtedRecords Commands.A sort field can be added to this command( in your context add the field id of "Item Status") and then add your search and execute the command.

This should work for your requirement. Hope it helps.

Regards,

Neeharika

Former Member
0 Kudos

Hi Prakasan,

Try something like

A2iResultSet rs = catalogData.GetResultSet(search, rsd, "SKU", true, page);

While(rs!=null)

{

rs1 = catalogData.GetResultSet(search1, rsd1, "itemstatus", true, page);

}

Hope it helps.

Thanks,

Minaz