G
Godfrey Sorita
Guest
You probably can't access the arrName variable because of the asynchronous nature of rbf_getFieldDef API. By the time you're accessing the variable, the data transfer and JavaScript operations are still running in the background. You can find out more about AJAX on this link: http://www.w3schools.com/ajax/ajax_intro.asp Below is a sample code for nested AJAX APIs: script src='../js/metadata.js' type='text/javascript' charset='utf-8' /script script var arrName = [], arrCount = [], count1 = 0, count2=0; $(function() { rbf_getFieldDef("object_a", "my_picklist", function(data){ //get the field definition of "mypicklist" field $(data).find('ListItem').each(function(){ //Loop all "ListItem" Nodes arrName[count1] = $(this).attr('Name'); rbf_selectNumber("SELECT count(1) FROM object_a WHERE my_picklist="+$(this).attr('Id'), function(data){ arrCount[count2] = data; count2++; if (count2==count1) runSucceedingScipt(); }); count1++; }); }); }); function runSucceedingScipt() { alert(arrName[0] + ":" + arrCount[0]); } /script However, please keep in mind that number of client-side API calls is limited per login session. You might hit this limitation fast depending on the number of picklist values you have. Godfrey
Continue reading...
Continue reading...