Querying for one of multiple-choice-checklist

Hello,

I am using Stable Runtime Version 4.84.7.

I am having a problem with querying on multiple-choice values using contains. I have a template in which I have selected the following values for allow_creation_from: On Demand Inspection, and Inspection Plan.

I attempt to query for templates where the allow_creation_from field contains “On Demand Inspection”. Here is my code for doing so:

Allow Creation From Constants

    view.templates = DB.checksheet_template.where("is_deleted != ? and (allow_creation_from contains ? or allow_creation_from = ?)", true, ALLOW_CREATION_FROM_ON_DEMAND_INSPECTION, ALLOW_CREATION_FROM_ON_DEMAND_INSPECTION)
        .orderBy("-last_modified_at").include("project","created_by");
    view.issue_templates = DB.checksheet_template.where("is_deleted != ? and (allow_creation_from contains ? or allow_creation_from = ?)", true, ALLOW_CREATION_FROM_ISSUE_REPORT, ALLOW_CREATION_FROM_ISSUE_REPORT)
        .orderBy("-last_modified_at").include("project","created_by");        

The second query (view.issue_templates) only has “Issue Report” selected, and I am able to query the issue templates successfully. However, the first query does not show up any results. When I only select “On Demand Inspection”, and remove “Inspection Plan”, I am able to query successfully though.

Shouldn’t the contains detect that I have “On Demand Inspection” selected? Or is there something wrong with my code?

Thanks,

Alex

1 Like

Hi Alex,

Your code looks correct and from testing within our test app, using contains should return this object as expected assuming that this object does not have is_deleted = true.

To look into this further, can you share a link to the application, a link to the user that we can test with, and instructions for testing?

Thanks!
Molly

Hi Molly,

Can you please provide instructions on how to share a link to my application?

@alex.dang please log a support ticket with the links and we can investigate from there.

Issue was unrelated, the code executes as expected