Skip to main content

Labeling Contracts for Filtering

Version 1.5 introduced ability to label contract objects before they are created so that later contracts list can be queried with those labels.


Let's say that you want to group contracts, you can do:

window.hapi.contract.state.contractForm = window.hapiUtils.mergeDeepOverwriteArrays(
window.hapi.contract.state.contractForm.value,
{
labels: {
group: "some-identifier-for-group"
}
}
)
note

We advise prefilling labels with listening to the following event to trigger the prefill:

window.hapi.contract.state.contractSelectedId.onChange(() => {
// run your prefill function
})

When user places creates a contract, this contract will have the label prefilled on contractForm object.


You can then use the new widget to query list of contracts with the labels (up to 50 maximum, with 32 maximum characters each key and value, both are case sensitive) you provided

<he-contract-list-layout-card-labels label1-key="group" label1-value="some-identifier-for-group"></he-contract-list-layout-card-labels>