;;webscript fieldbrokerlist( Integer nodeId, Integer listLen, RecArray brokersRec, Integer libraryReference, Assoc template = Undefined, Record request = undefined )
// listLen, the length of pulldownn menu (Usually 1 for popup or 4 for multi-select)
// recs, all brokers
// nodeID is deprecated
;Dynamic rec
;Object prgCtx //section 508
;String locationName
;String locationId
;String withinQuery = ""
;List hilightList = { libraryReference }
;Boolean IsInList = False
;Boolean doPopup = ( listLen == 1 )
;Boolean FromHereExpanded = FALSE
;Integer i = 1
;String key = 'collections'
;Boolean noApplet = FALSE
;if IsDefined( request ) && IsFeature( request, "prgCtx" )
;prgCtx = request.prgCtx
;else
;prgCtx = .PrgSession()
;end
;noApplet = $Webll.WebUtils.NoJavaInHTML( prgCtx ) //section 508
;if ( isFeature( request, "withinQuery" ) && ( str.lower(request.withinQuery ) in { "yes","true" } ) ) || ( isFeature( template,"withinQuery" ) && ( str.lower( template.withinQuery ) in { "yes","true" } ))
;FromHereExpanded = TRUE
;end
;if IsDefined( template )
;locationName = template.locationName
;locationId = template.locationId
;if isDefined( locationName ) && isDefined( locationId )
;withinQuery = template.withinQuery
;else
;FromHereExpanded = FALSE
;end
;if IsDefined( template.collections )
;hilightList = template.collections.components
;end
// try from request first
;if IsDefined( request )
;if IsFeature( request,'collections_search_selected_list' ) || IsFeature( request,'collections_search_selected' )
;hilightList = _GetBrokerListFromRequest(request )
;end
;end
;end
// If the user did not get here from the
// From Here (Expanded)... link, we sort
// the brokers.
;if ( IsDefined( brokersRec ) && Length( request ) > 1 )
;if ( !FromHereExpanded && !dopopup )
;RecArray.Sort( brokersRec, 'name', False )
;end
;end
// try from request
;if IsUndefined( locationId ) && IsDefined( request )
;if Length( request.locationId ) > 0 && request.locationName == 'TRUE' && IsDefined( request.withinQuery )
;locationName = request.locationName
;withinQuery = request.withinQuery
;locationId = request.locationId
;end
;end
;if ( noApplet ) //section 508
;if ( ( Length( locationName ) > 0 ) && doPopup )