application.getValueListDisplayValue() not return the value

Hi,
I have a problem when using application.getValueListDisplayValue() to get the displayed value. It did get the real value but returned of the displayed value. This only happened when I called application.getValueListDisplayValue(). The displayed value showed in the form correctly when running the solution and loading the records.
The valuelist goes through a relation and it’s “No N-M relation”. Is this a problem? but if this is the problem then why the displayed value can be shown in the form?

Has someone had this kind of problem?

Thanks,

Hmm, I don’t really understand what you try to do.

When you want to find out what value was selected you should check the dataprovider that is attached to the field with the valuelist.

When you want to know what display value belongs to the (selected) real value you can do application.getValueListDisplayValue(valuelistName, realValue)…

IT2Be:
Hmm, I don’t really understand what you try to do.

When you want to find out what value was selected you should check the dataprovider that is attached to the field with the valuelist.

When you want to know what display value belongs to the (selected) real value you can do application.getValueListDisplayValue(valuelistName, realValue)…

I want to know what display value belongs to the (selected) real value and I used application.getValueListDisplayValue(valuelistName,realValue). But it returned null to me. Since this value list goes through a relation, I tried changing the relation to the table, then I got the displayed value. But I shouldn’t change it. I’d like to know if application.getValueListDisplayValue(valuelistName,realValue) doesn’t work for the value list which goes through a relation?

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!

Thank you.
In my case, the returned value is not always unique. So I’m thinking to find another way. Because the value will be shown on the screen first then I need to reuse the value, how can I access the field to get the current value? If I do this way then I don’t need to use application.getValueListDisplayValue() method. I just need to get all values from the fields. I tried some methods but I cannot get the value shown in the fields. What I got is just the value of the data provider. This value is just a ID not the real value shown on the screen.
Do you know if there is a way to get the displayed value in the fields?

banff.moon:
Do you know if there is a way to get the displayed value in the fields?

2 ways:

  1. query your childtable on the foreignkey and the value of the dataprovider. This combination should be unique
  2. build a 2nd relationship: this is like the relationship you use to show the valuelist, but then add 1 more condition: globals.returnValue = returnValue

using option 2, set the global variable with the value of the dataprovider and then get the related value using the relationship.

My method is global method. Many forms can call this method. All of these forms have value lists. So I cannot hard code the global variable. In this method the value list which will be accessed is unknown, it depends on which form calls it.
If I use global variable to remember a returned value how can I tell if this value list has a global variable attached?

If I use global variable to remember a returned value how can I tell if this value list has a global variable attached?

It doesn’t: just use the global variable to set it with the returned value in the record when looping through your records/dataset, get your value and process it…

Further on:
As this is a global problem, I suggest you explore the possibilities of the solutionModel a bit more. Steps to go:

  1. based on the jsValuelist (which you’ve got from $smField.valuelist) you could determine the type of valuelist and if this is a relationbased type, read the relationname.
  2. use solutionModel.getRelation(‘relationname’) to make a jsRelation
  3. now you can read foreign table/servername and relationitems
  4. from the relationshipitems read the properties.

Step 1-4 are ment to gather all information.
Last step 5 is: build your query based on all the information and return a value.

Another option:
build a relationship dynamically and use this to read the value.
This could be done using the global variable as I described before…

Anyway, this is gonna be some work, but the keyword is ‘solutionModel’…

Good luck!

mboegem:
Anyway, this is gonna be some work, but the keyword is ‘solutionModel’…

I searched Servou forum and ServoyClient4UserGuide, ServoyDev4ReferenceGuide and ServoyDev4UserGuide, couldn’t find information about how to use JSValuelist. When I click on JSValueList in Servoy there’s no any property or methods. I have no idea how to use it to get the type of valuelist.
Can you tell me where I can find the information?

Thanks,

mboegem:
Anyway, this is gonna be some work, but the keyword is ‘solutionModel’…

I’m using Servoy v4.1.0 b1. There’s no solutionModel.newRelation() in this release. Which release has this function?

banff.moon:
Which release has this function?

v4.1.0 final has been released about 2 weeks already. I think you should upgrade to this version as it is much more stable than beta versions.

banff.moon:
Can you tell me where I can find the information?

At http://www.servoy.com/generic.jsp?mt=396&taxonomy_id=790 there’s some information on the solutionModel.
There’s no real documentation on this as it’s all very new.
We’ve been playing around (and still learning) a lot and that’s the only way to learn & understand the whole idea behind it.

Just write your code and use application.output() or the debugger to see what Servoy’s output is at the several stages of your code.
You really don’t have to understand each function. As soon as you have your first working example with the solutionModel (it can be as simple as creating a new Form in tableview and placing some fields on it), you will experience it’s all the same.

mboegem:
v4.1.0 final has been released about 2 weeks already. I think you should upgrade to this version as it is much more stable than beta versions.

How to upgrade? I tried running java -jar servoy_updater.jar in servoy directory but it said “no update found”. I re-ran servoy it is still v4.1.0 b1.
Is there other way to upgrade?

banff.moon:
How to upgrade?

just type: ‘servoy_updater’ in servoy directory, for a final release this should be enough…

Hmm…I think I saw this too. Seems you have to go through all the beta’s to get to the final.
So use the following until you are at the final version.

java -jar servoy_updater.jar -beta

Hope this helps.

I use “solutionModel.getForm(form).getField(fieldName).valuelist” to get a jsValuelist. Does anybody know how to get the type of valuelist? In my servoy when I clicked JSValueList no any method shows up. So I don’t know what methods I can use.

Thanks,

Does anybody know how to get the type of valuelist?

What do you mean with type?

IT2Be:

Does anybody know how to get the type of valuelist?

What do you mean with type?

I was wrong. I’d like to get relation name from the JSValueList;
I’v done this but when I get the record by using forms[form].foundset.getRecord(index) and try record.relationname.find(), why it doesn’t work?

There is a jsvaluelist node in the solution explorer tree under solutionModel.
It has a property called valueListType (see the bottom list when you select the jsvaluelist node).

There are constants for it defined in the SolutionModel->Constants node.

Rob