Update the map broker implementation

  • Versão de lançamento: Australia
  • Atualizado 12 de mar. de 2026
  • 1 min. de leitura
  • Updating the map broker implementation allows you to use a custom table that stores the new map markers you want to use.

    Antes de Iniciar

    Role required: admin

    Por Que e Quando Desempenhar Esta Tarefa

    In this procedure we're updating the DispatcherWorkspaceMapBrokerImpl (Data Broker) in the file sys_script_include_034c249053017110443cddeeff7b126a.xml.

    The override method is described below. To override, copy the entire method from parent DispatcherWorkspaceMapBrokerImplSNC, then add resource handling logic. What is added:

    • Calls parent method first, DispatcherWorkspaceMapBrokerImplSNC.prototype.getMapMarkers.call(this, params).

    • Adds resource marker generation after agent/task markers.
    • Merges resource markers with existing markers.
    • Updates marker count and warning flags

    Procedimento

    Review the code below and make updates accordingly.
    ```javascript
    getMapMarkers: function(params) {
    	// Call parent to get agents and tasks
    	var result = DispatcherWorkspaceMapBrokerImplSNC.prototype.getMapMarkers.call(this, params);
    	
    	var markers = result.markers;
    	var markersMap = result.markersMap;
    	var remainder = result.remainderMarkersAllowed;
    	var showWarning = result.showWarning;
    	var message = result.warningMessage;
    	var max = result.maxMapMarkers;
    	
    	// Add resource marker handling
    	if (remainder > 0) {
    		var resourceData = this._getResourcesWithLocation(params);
    		
    		if (!gs.nil(resourceData) && Object.keys(resourceData).length > 0) {
    			var resourceIds = Object.keys(resourceData);
    			
    			// Generate resource markers using mapUtil
    			var resourceKeyMap = {};
    			var resourceRes = this.mapUtil.getResourceMarkers(
    				resourceData, 
    				resourceIds, 
    				markersMap, 
    				resourceKeyMap, 
    				remainder
    			);
    			
    			// Merge resource markers with existing markers
    			markers = markers.concat(resourceRes.markers);
    			
    			// Update warning if hit limit
    			if (resourceRes.showWarning) {
    				showWarning = true;
    			}
    			
    			// Update remaining count
    			remainder = remainder - resourceRes.count;
    		}
    	}
    	
    	// Return updated result
    	return {
    		markers: markers,
    		getTaskPanelDataFromClientState: result.getTaskPanelDataFromClientState,
    		taskPanelTasks: result.taskPanelTasks,
    		showWarning: showWarning,
    		warningMessage: message,
    		maxMapMarkers: max,
    		remainderMarkersAllowed: remainder,
    		markersMap: markersMap,
    		agentMarkersCount: result.agentMarkersCount
    	};
    }
    ```
    
    #### New Methods:
    - **`_getResourcesWithLocation(params)`**
      - Purpose: Queries database for FSM resources with location data
      - Queries: `sn_fsm_resource` table joined with `cmn_location`
      - Returns: Object map of resource data with `{displayValue, loc, address, resource_type, status}`
    
    ```javascript
    _getResourcesWithLocation: function(params) {
    	var resourceData = {};
    	
    	// Query resources from sn_fsm_resource table
    	var gr = new GlideRecord('sn_fsm_resource');
    	gr.addActiveQuery();
    	gr.query();
    	
    	while (gr.next()) {
    		var locationId = gr.getValue('location');
    		if (!gs.nil(locationId)) {
    			var locGr = new GlideRecord('cmn_location');
    			if (locGr.get(locationId)) {
    				var lat = locGr.getValue('latitude');
    				var lng = locGr.getValue('longitude');
    				if (!gs.nil(lat) && !gs.nil(lng)) {
    					resourceData[gr.sys_id + ''] = {
    						displayValue: gr.getDisplayValue(),
    						loc: { lat: parseFloat(lat), lng: parseFloat(lng) },
    						address: locGr.getValue('name') || '',
    						resource_type: gr.getValue('resource_type'),
    						status: gr.getValue('status')
    					};
    				}
    			}
    		}
    	}
    	
    	return resourceData;
    }
    ```