Skip to main content

How to upsert custom Search Attributes to Workflow during Execution

Inside a Workflow, we can read from WorkflowInfo.searchAttributes and call upsertSearchAttributes:

search-attributes/src/workflows.ts

export async function example(): Promise<SearchAttributes> {
const customInt = (workflowInfo().searchAttributes.CustomIntField?.[0] as number) || 0;
upsertSearchAttributes({
// overwrite the existing CustomIntField: [2]
CustomIntField: [customInt + 1],

// delete the existing CustomBoolField: [true]
CustomBoolField: [],

// add a new value
CustomDoubleField: [3.14],
});
return workflowInfo().searchAttributes;
}