valuelists

Hi,

I need a valuelist that has values depending on another field in the same record.
I am now using a global method valuelist.
This almost does what I need.
When i select different records in list view or record view, the valuelist has different values depending on one of the fields in the same record.
Thats good !!

But when i edit the record and change the field the valuelist is depending on, the valuelist does not change.
When I then save the data and go to the next record and back, the valuelist displays the correct values.

So it seems that the global method is called on next and prev record, but it is not called when a field within a record is changed.
I checked this ( debug breakpoint ) and that confirms this behaviour.

Is this intended behaviour and if so how can I get the valuelist to be repopulated when I change the field ??

My global method :

function getDataSetForValueList(displayValue, realValue, record, valueListName) {
	if (displayValue == null && realValue == null) {
		if (record) {
			if (record.hntext == 'incourant') {
				return databaseManager.getDataSetByQuery("udm", "select text,id from hn", null, 100);
			} else {
				return databaseManager.getDataSetByQuery("udm", "select text,id from hn where courant=1", null, 100);
			}
		} else {
			return databaseManager.getDataSetByQuery("udm", "select text,id from hn where courant=1", null, 100);
		}

	} else if (displayValue != null) {
		var args = [displayValue + "%"]
		return databaseManager.getDataSetByQuery("udm", "select text,id from hn where courant=1 and text like ?", args, 100);
	} else if (realValue != null) {
		args = [realValue];
		return databaseManager.getDataSetByQuery("udm", "select text,id from hn where id=?", args, 100);
	}
	return null;
}

Hi Hans,

I presume, perhaps mistakenly, that the population of this valuelist (i.e. the global method) gets triggered by the record selection. Is that correct? Is it also triggered onDataChange for the field needed for the valuelist?

Hi John,

The population is done by Servoy, since it is a standard valuelist of type : global method.

Regards,

yes it is by design that it is not called on every change of that record…
For this i guess you need to somehow use a related valuelist.

Ah, misunderstood. However it might be worth amending it slightly to be a ‘custom’ valuelist that instead gets populated by your code and triggered by on record selection or data change. I use this on a number of solution where I am winnowing down a selection of 10’000 or so diagnoses and giving the user a final pick list of 2 or 3 depending on the values they enter for sites and histology. There’s never been an issue with speed with that I’ve found.

@ Jhon : thanks, I think for now that is the way to go…

@Johan : a function like repopulateValueList would be very nice.
The developer then can decide to repopulate the ( global method ) valuelist in an onDataChange (or other) event.
Would make the Global Method Valuelist the best option for these situations and it would require almost no extra code.
A related valuelist will not do in these situations.

Regards,

hans: Do make a case for this then. Then we can see if this is easy/nicely possible.

+1 Yes, please !

We know often change the dataprovider value to -1 to trigger a repopulate of the bound global method valuelist (mode : display value and real value both null) but we sometimes see that -1 in the ui.
Setting the value to null does not trigger the repopulate.

We often use global objects in the global method to add context info for the dataset SQL query and in those cases the repopulate is almost always needed.

Regards,

Created case SVY-1376

regards,