How to Properly Publish a DataRecordsSelectionChangeMessage Message?

111
1
yesterday
Labels (1)
DavidSolari
MVP Regular Contributor

I'm working on a widget for ExB 1.17 that will select a point and a polygon feature from the map's data sources if a selection action is added to the widget. I was able to get the Extent Change message type handled pretty easily so I figured this would be fine too, but instead I get this error after the message is published:

Bad jimuLayerViewId:widget_6-dataSource_2-<layer_name_here>

I'm incredibly confused because the actual ID's I'm passing in look like this:

dataSource_1-<layer_name_here>

This means the completely separate Data Source from the other half of my map widget is getting into the message somehow? My actions look just fine in the settings panel and I don't see any obvious issues with my invoker function, anything I'm missing here?

const invokeSelectionMessages = async (polyJlv: JimuLayerView, polyResult: Graphic, pointJlv: JimuLayerView, pointResult: Graphic, widgetId: string) => {
  const polyDs = await polyJlv.getOrCreateLayerDataSource() as QueriableDataSource;
  const pointDs = await pointJlv.getOrCreateLayerDataSource() as QueriableDataSource;
  const polyId = String(polyResult.getObjectId());
  const pointId = String(pointResult.getObjectId());
  const polyRecord = await polyDs.loadById(polyId, true);
  const pointRecord = await pointDs.loadById(pointId, true);
  polyDs.selectRecordById(polyId, polyRecord);
  pointDs.selectRecordById(pointId, pointRecord);
  MessageManager.getInstance().publishMessage(new DataRecordsSelectionChangeMessage(
    widgetId,
    [polyRecord, pointRecord],
    [polyDs.id, pointDs.id]
  ));
}

I tried running two publish actions (one per data source) but that just creates two errors.

0 Kudos
1 Reply
DavidSolari
MVP Regular Contributor

I did a bit more testing and it looks like my chosen action (flash the data on the map) is actually working despite the error. Is this a benign error for all actions? I'd prefer not to dump weird errors into the console every time a user runs a task but that's better than not having it work at all.

0 Kudos