Filter workflow options with custom script

Hey guys, I’m trying to figure out how to filter the options that a user can select based on a field in the document. Anyone done this?

frappe.ui.form.on("Purchase Receipt", {
    onload: function(frm) {
        if( frm.doc.class_a) {
            [FILTER WORKFLOW STATE TO ONLY ALLOW QA INSPECTION]
        } else {
            [FILTER WORKFLOW STATE TO ONLY ALLOW PD INSPECTION]
        }
    }
});

Hi, how about set_query or it doesn’t suit you? I think if you options is a list of documents you should use a set_query and if your options for select fieldtype you should use set_field_options function.