cancel
Showing results for 
Search instead for 
Did you mean: 

Display lookup field record values for the main table (dynamically)

Former Member
0 Kudos

Hello All,

I wanted to display all the records(text, lookupfields, qualified) in any given repository. And this should happen dynamically, ie If the user selects the table name from a drop down he must be able to see all the records relating to it. Iam able to get the simple fields but not able to get the lookup table records, below is my code which works for simple fields, what changes should i make to display the qualified records too. can anyone please help.

try{

String selectedTable = wdContext.currentVnDropdownElement().getVaresult();

ResultSetDefinition resultdefenition = new ResultSetDefinition(selectedTable);

for(int i=0; i<code.length;i++)

{

resultdefenition.AddField(code<i>);

}

Search search = new Search(selectedTable);

A2iResultSet rs = catalog.GetResultSet(search, resultdefenition, null, true, 0);

int recordCount = rs.GetRecordCount();

Value value2 = null;

for (int ij=0; ij < recordCount; ij++)

{

IPrivateLogin.ITableValuesElement TableEle=wdContext.createTableValuesElement();

wdContext.nodeTableValues().addElement(TableEle);

for (int j = 0; j < rs.GetFields().GetCount(); j++)

{

value2 = rs.GetValueAt(ij,j);

if (value2.IsNull())

{

value2 = value2.Set("NA");

}

//TableEle.setVaAllRecords(value2.GetStringValue());

}

}

}catch(StringException e){

wdComponentAPI.getMessageManager().reportSuccess("INSIDE CATCH BLOCK" + e);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Suresh,

A2iResultSet rs = catalog.GetResultSet(search, resultdefenition, null, true, 0);

//Get lookupfield -->You have to get the id instead the value. Then access to the main table with the id. Example: position = number of record of the resultset, lookckupfieldname = name of the lookupfield

A2iIntArray agArray = rs.<b>GetLookupIDAt</b>(position,lookupfieldname);

//Go to main table to get the "real" value

int tableID = agArray.getAt(0);

A2iIntArray ids = null;

ids = new A2iIntArray();

ids.Add(tableID);

rsd = new ResultSetDefinition(tableName);

rsd.AddField(fieldnameinmaintable);

Search search = new Search(mainTableName);

resultSet = catalogData.<b>GetRecordsById</b>(rsd, ids);

//Get qualified fields --> with the recordID first get the qualifiedlink of the fieldwanted. After, for each link go to find it "real2 value. Example:

// Get the recordID

Search search = new Search(tablename);

QualifiedLinkArray qualifiedLinkArray;

// get the qualifer qualifiedLink of the record

qualifiedLinkArray =

catalogData.<b>GetQualifiedLinks</b>(search, tablename, qualifiedfieldname, recordId);

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

{

// get qualifiedLink

QualifiedLink qualifiedLink = qualifiedLinkArray.<b>GetQualifiedLinkAt</b>(i);

// get the lookup Record value

int id = <b>qualifiedLink.GetLookupID</b>();

//With this id you can go to the main table an gets the values that you want

}

Regards

Answers (0)