I tried it also but didn’t got it to work when a valuelist is based on a relation.
In some way I can understand this, because this valuelist would normally show you values based on a ‘parent’ record.
This means your scope is a record with a specific value.
Using application.getValueListDisplayValue(valuelistName, realValue) is something without a scope, it’s global. At this point the relation on which your valuelist is based can not be evaluated.
So thinking of a possibility to help you out:
if the value returned from your current valuelist is unique, you could create a second valuelist based on all values from the ‘child’ table (of course returning/displaying the same values).
Then use this valuelist in application.getValueListDisplayValue(valuelistName, realValue).
Example:
parent table has primaryId, textField_xyz
child table has foreignId, textField_returnvalue, textField_displayvalue.
Let’s say the child table contains 4 records with foreignId’s: 1, 1, 2, 2 > returnvalues: A,B,C,D > displayvalue: disp_A, disp_B, disp_C, disp_D
The parent table has 2 records with primaryId’s: 1 and 2.
Based on the first record you will see a valuelist showing A and B
Based on the second record you will see a valuelist showing C and D
Using the valuelist ‘relatedValues’ over the relationship parent_table_to_child_table, primaryId = foreignId, will return null when executing: application.getValueListDisplayValue(‘relatedValues’, ‘D’)
Using the valuelist ‘allValues’ showing all values of the child table, will return ‘disp_D’ when executing: application.getValueListDisplayValue(‘relatedValues’, ‘D’)
A mentioned before, this can only happen when the returnvalues are unique…
Hope this can help you!