Using set_value function with serverList

Hi!
In my lightbox form I have a custom field and I use the set_value function for retrieve value:

set_value:function(node, value, ev) {					    					
node.childNodes[1].value = value || "";
node.childNodes[4].value = ev.details || "";
}

The problem is that my custom field is mapped to a foreign key and I tried to get the correct value to display via the dhtmlxOptionsConnector like this without any result :

node.childNodes[1].value = value || scheduler.serverList("documents");

The serverList is populated with the correct table.
I must use a custom field and I cannot use a select type field.
Is it possible to do this ? And if yes how I can do this thing?
Thanks for your help!

There is no built-in helpers for such use-case, you need to write a simple helper function which will iterate through server list collection ( it is an array of objects ) and convert value to label or label to value.

Something like

var options = scheduler.serverList("documents"); for (var j=0; j<options.length; j++) { if(options[j].key == value) { return options[j].label; } }

Thank you, with your help I populate the custom field correctly.
Now I’m a little bit confused about what happens in the lightbox configuration.
For test I configured my lightbox with a select field that retrieve the data from the serverList and in the same lightbox I configured my custom field like this :

{name:"document", height:21, options:scheduler.serverList("documents"), map_to:"fk_doc", type:"select"}, {name:"document", height: 21, map_to:"fk_doc", type:"custom_docs"},
With this configuration all work correctly and in the “set_value function”, for the custom field, I use the javascript helper function.
In production I want to remove the “select field” and use only the custom field. When i perform this operation the “scheduler.serverList(“documents”)” stop run and return always 0 items (instead 2000 item).
If I restore the “select field” the “scheduler.serverList(“documents”)” return to run correctly.
How can avoid this problem?
Do I need to instantiate the “scheduler.serverList(“documents”)” object ?

Do I need to instantiate the "scheduler.serverList(“documents”)

Yep, just add the next line before lightbox configurution.

scheduler.serverList("documents");

It will create a list collection, and it will be correctly filled after data loading.
( basically you need to call a serverList with collection name at least once before data loading, to register name for future loading )