on 04-13-2009 4:20 PM
Hello,
I have a namedsearch say plant_xxx.
Can we read the records in this namedsearch using mdm java api's.
If so, please let me know the code snippet to get the records in this namedsearch.
Thanks
MLS
Hi Laxmi,
Yes, we can read records in the named serach. We have to use NamedSearchSearchDimension & PickListSerachConstarint to read records in particular named search, all repository named searches will be stored in Named Serch table, so we need to get record id of particular named search (ex Plant_xx) and pass MDM value to PickListSearchConstarint.
Plz see the below code
TableSchema tableSchema = schema.getTableSchema("main table Code"); // Ex vendor,product etc....
Search objSearch = new Search(tableSchema.getTable().getId());
RecordId recordId = new RecordId("R1"); // Record id of Named Search (plant_xxx) in Named serach table
SearchDimension searchDimension = new NamedSearchSearchDimension();
MdmValue requestValue = new LookupValue(recordId);
MdmValue[] values = ;
SearchConstraint searchConstraint = new PickListSearchConstraint(values);
SearchParameter searchParameter = new SearchParameter(searchDimension, searchConstraint);
objSearch.addSearchItem(searchParameter);
ResultDefinition resultDef = new ResultDefinition(tableSchema.getTable().getId());
resultDef.setSelectFields(tableSchema.getFieldIds());
RetrieveLimitedRecordsCommand limitingCommand;
try {
limitingCommand = new RetrieveLimitedRecordsCommand(context);
limitingCommand.setResultDefinition(resultDef);
limitingCommand.setSearch(objSearch);
limitingCommand.execute();
} catch (SessionException e) {
} catch (ConnectionException e) {
} catch (CommandException e) {
throw new VendorException(e);
}
if(limitingCommand.getRecords()!= null){
System.out.println("Number of records:"+limitingCommand.getRecords().getCount());
Record [] records = limitingCommand.getRecords().getRecords();
for (int i = 0; i < records.length; i++) {
System.out.println("Record ["i"]: Value "+records<i>.getDisplayValue());
}
}else{
System.out.println("no records:");
}
Hope it helps.......
Cheers,
Veeru
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.