Using senaite.app.listing.api "set_fields" function for listing view buttons

Hello!

In the table listing view for Analyses where results are entered directly for a individual sample, our lab is trying to add a feature to auto-populate every analysis on that sample with the data entered into the first row on a per-field basis (similar to how the AR Add form works).

I noticed there is an API function in senaite.app.listing called set_fields that seems like it is designed to do this very thing.

Does anyone have an example of implementing that function in a button, or know of a better solution to use? My ReactJS is still a bit weak and I’ve been in a rabbit hole of how the Promise object works.

Or would it be simpler to design it similar to the AR Add form copy button even though the fields are displayed as columns and not rows, and the function is indicated as needing refactoring?

Hi @faytrow,

you can have a look into this snippet how the worksheet interims are applied over all analyses:

However, we recently added a modal popup functionality to set all remarks for worksheets here:

This would be probably a better fit for what you are planning to do.

So basically you need to add an adapter like here:

and apply a custom transition for the button like here:

1 Like

Awesome! That’s exactly the sort of functionality I was searching for, and prompting workflow transition with a modal is something I’ve wanted to implement in a couple places for awhile now. :slight_smile:

Thanks @ramonski !