Get value of search attribute from ScanWorkflowExecutionsResponse

I’m using the ScanWorkflowExecutionsResponse to get all workflow executions currently running.
I’m trying to get the value of one of the custom search attribute I added. So far this is where I’m stuck

ScanWorkflowExecutionsRequest scanWorkflowExecutionsRequest = ScanWorkflowExecutionsRequest.newBuilder().setNamespace(NAMESPACE).setQuery(query).build()
            ScanWorkflowExecutionsResponse scan = service.blockingStub().scanWorkflowExecutions(scanWorkflowExecutionsRequest)

for (WorkflowExecutionInfo exec : scan.executionsList) {
  SearchAttributes searchAttributes = exec.getSearchAttributes()

From the SearchAttributes, I’m not sure how to get the value of my custom attribute.
Is there like a getField('customAttr')


Hello @Jerome_John

you can use one of the following methods to get the value:

  • exec.getSearchAttributes().getIndexedFieldsMap().get("customAttr")
  • exec.getSearchAttributes().getIndexedFieldsOrThrow("customAttr")
  • or exec.getSearchAttributes().getIndexedFieldsOrDefault()

Then get the data attribute from the returned payload and decode it to string getData().toStringUtf8().