on 2007 Apr 30 10:27 AM
hi Everybody,
I am Looking for help to fetch Flat look Up Field Values.
I am trying to find the value of a field ( which is of type Flat look Up) for a particular record in the main table. I'm able to fetch TEXT ( direct ) fields from the table but seems there is some specific method to get the value for look up field.
While trying to get the value of this field, I'm getting RecordID of the same. With which I can certainly go n search the lookup table. But it doesnt look efficient to me.
Even a small hint would will be really helpful.
Regards
Namrta Mahajan
<b>Record.findLookupRecords(FieldId)</b> - Will help you to fetch the lookup records associated with main table..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Namrta,
Please find the sample to retrieve the Look up Field values:
Hope you would be retrieving the TEXT data using Record.getFieldValue(FieldId) API.
Consider the following Exampple:
<b>Table : Person
Field Name | Field Code| Type
Name | NAME | TEXT
Address | ADDR | Lookup[Flat]
Table : Address
Address Id | ADDR_ID | TEXT
Address Line1 | ADDR_LN_1| text</b> (Could be a display field)
Let's say you are intrested in looking for Address Line1 from table Person.
for retrieving the value of the name you would be using:
<b>FieldId nameFieldId = repositorySchema.getFieldId('Person','NAME').getId();
FieldId addressFieldId = repositorySchema.getFieldId('Person','ADDR').getId();
FieldId addressLine1FieldId = repositorySchema.getFieldId('Address','ADDR_LN_1').getId();
String name = Record.getFieldValue(nameFieldId).toString();</b>
For Flat Lookup field Value :
<b>MdmValue mdmValue = Record.getFieldValue(addressFieldId);</b>
Check for the following condition (This block would enter if and only if the field contains value!)
<b>String addressLine1 = null;
if(mdmValue.getType() != MdmValue.Type.NULL && mdmValue.getType() == MdmValue.Type.LOOKUP){
Record[] addressRecords = Record.findLookupRecords(addressFieldId);
if(null != addressRecords){
addressLine1 = addressRecords[0].getFieldValue(addressLine1FieldId);
}
}</b>
Code at this line must have addressLine1 populated with lookupvalue.
Hope it helps.. Sorry for delay in response...........
Regards,
Guru
Message was edited by:
Gurushant Hanchinal
Found the solution , But thats very long way, still trying to find some other way for it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Which API are you using?
Walter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Namrata ,
It seems page 110 of console manager will help you in 'display fields' of lookup fields .
Hope it helps ,
- An
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello:
Actually the way you are doing it is the right way. In the main table, get the lookup field ID. With this ID, go to the lookup table and retrieve the record.
it's quite efficient, because in this way you can get all the fields of the lookup table, which are not loaded when you get only the main table
I hope this helps
Alejandro
User | Count |
---|---|
73 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.