cancel
Showing results for 
Search instead for 
Did you mean: 

MDM API to get lookup field value

Former Member
0 Kudos

I have retrieved the record I am looking for from my main table using the MDM API - One of the fields of the main table is a flat lookup field. If I use getLookupDisplayValue(), it returns something like "TU, Turkey". The actual lookup table consists of fields "code" and "name". I only want to fetch the "code" value - Not a comma separated value which includes the name value.

So my main table name is "plant_extensions", and the lookup table name is "enterprises".

I have tried to use the following code:


...
Record rcArray[] = plant_record.findLookupRecords(field_id);

This returns only one value which is correct. I then want to get the value in the "code" field of the lookup table, so I do the following:


rcArray[0].getLookupDisplayValue(getFieldId("lookup_table_name", "code");

For some reason, it won't accept this field ID - It says that it has not been maintained, or does not exist.

Am I doing this the correct way, or is there a better way to do this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi David,

Refer

Hope it helps.

Thanks,

Minaz

Former Member
0 Kudos

Thanks Minaz - I actually read that post earlier, but after reading it a second time I managed to sort it out.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi David,

when all the lookup records are retrived, as you did by the below code.

Record rcArray[] = plant_record.findLookupRecords(field_id);

The Display value and the lookup Id can be retrived as follows:-

Display value = rcArray[0].getDisplayValue();

Lookup Id = rcArray[0].getId();

Hope it helps.

Regards,

Neeharika