cancel
Showing results for 
Search instead for 
Did you mean: 

MDM search does not return values

Former Member
0 Kudos

I am having some difficulty in retrieving values from my MDM system. My goal is to retrieve an MDM record by ID and then place those values into an ArrayList.

When I call the retrieve method it returns a record and I can retrieve the correct ID from that record. The problem is that none of the field values are populated (for Name 1 and Name 2 fields there are rows in the ArrayList but no values). I am running NW2004S SP09 with MDM 5.5 SP 4 Patch 1.

I have been able to successfully add fields to MDM through the API so I know the connection informaiton and Code values are correct. I can see values for the record id that I am passing in from inside the Data Manager.

The code is as follows:

public ArrayList retrieveCustomer(int id) {

// TODO : Implement

loc.setMinimumSeverity(Severity.ALL);

loc.addLog(new ConsoleLog());

loc.entering(retrieveCustomerMsg);

// create connection pool

final String tag = "";

// ArrayList to store return values

ArrayList customers = new ArrayList();

String tableName = "MDM_CUSTOMERS";

try {

// call function to open connection

IConnection connection =

getConnection("<server hidden>", "<uid hidden>", "<password hidden>", "<port hidden>");

// call function to open catalog object

CatalogData catalog = getCatalog(connection);

Search s = null;

ResultSetDefinition rsd = null;

// set search parameters

Search search = new Search(tableName);

rsd = new ResultSetDefinition(tableName);

// set search fields

CMFieldInfoArray fieldInfoArray = catalog.GetFields(tableName);

for (int i = 0; i < fieldInfoArray.GetSize(); i++) {

CMFieldInfo fieldInfo = fieldInfoArray.GetCMFieldInfoAt(i);

rsd.AddField(fieldInfo.GetCode());

}

// create int array to store search id

A2iIntArray idArray = new A2iIntArray();

// add id from parameters to intArray

idArray.Add(id);

// query result

A2iResultSet searchResult =

catalog.GetRecordsById(rsd, idArray);

// debug rs count

customers.add(new Integer(searchResult.GetRecordCount()));

for (int i = 0; i < searchResult.GetRecordCount(); i++) {

// Add elements as a row in the ArrayList

customers.add(0, new Integer(searchResult.GetRecordIDAt(0)));

if (!searchResult.GetValueAt(i, "Name 1").IsNull()) {

customers.add(

1,

searchResult.GetValueAt(i, "Name 1").GetStringValue());

} else {

customers.add(1, "");

}

if (!searchResult.GetValueAt(i, "Name 2").IsNull()) {

customers.add(

2,

searchResult.GetValueAt(i, "Name 2").GetStringValue());

} else {

customers.add(2, "");

}

}

// close connection

closeConnection(connection);

} catch (StringException se) {

loc.fatalT(se.toString());

}

return customers;

}

Any ideas on this? All help is greatly appreciated.

Best Regards

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

The problem in this code was with the ID. We were querying the record based on the autoid displayed in the data manager. This was not the actual id of the record in MDM.

Thanks all who responded.

Former Member
0 Kudos

Hello Tyson,

I would try changing the line

rsd.AddField(fieldInfo.GetCode());

to

rsd.AddField(fieldInfo.GetName());

then you can leave the GetValueAt(i, "Name 1").GetStringValue();

as is.

Former Member
0 Kudos

Hey Tyson

Looks like there is a small problem in the code...

searchResult.GetValueAt(i, "Name 1").GetStringValue()

In the above line of code, <b>Name 1</b> is the name of the field. But I think you need to pass the <b>code</b> of the field as a parameter for this method. I assumed it to be the name of the field because, the code doesn't accept blank spaces.

If you look at the table in the MDM Console, every field has a name and also a code. Use the value in the <b>Code</b> as an input parameter to the method.

HTH

Suman

Former Member
0 Kudos

Thank you.

"Name 1" is the Code value of the field. I tried to use another field that does not have a space in the Code field, for example "Customer"

Even when trying to query the value for the for the field with the code "Customer" nothing is returned.

Regards

Former Member
0 Kudos

Hi,

Not sure but try using..

GetValueAt(int row, int column)

Returns the field value at specified row and column.

for retieval of info..

Regards,

Tanveer.