Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom field choice filtering matches multiple choices #1513

Closed
jvanderaa opened this issue Sep 19, 2017 · 11 comments
Closed

Custom field choice filtering matches multiple choices #1513

jvanderaa opened this issue Sep 19, 2017 · 11 comments
Assignees
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@jvanderaa
Copy link
Contributor

jvanderaa commented Sep 19, 2017

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation

Environment

  • Python version: Python 3.5.2
  • NetBox version: 2.1.4 (updated - previously wrote down wrong version of 2.0.5)

DCIM Custom Field Search - Returning Wrong Info

I setup a custom field to maintain our support contract information for each of the devices. I originally had 3 choices setup. I then got a bigger list of contracts and am now up to 13. When I search for devices in a field that I state has one coverage, devices with "Needs Coverage" show up. I click into the device and it has the custom field setup properly. When checking the API, it also reports the proper field back. However when I search for devices of each field type, they are showing up in the wrong place.

####Steps to Reproduce:

  1. Click on Devices -> Devices
  2. Go down the right hand column and select the drop down of the custom field (drop down field)
  3. Search for devices, and devices with that custom field setting show up.
@jeremystretch
Copy link
Member

Please upgrade to the most recent release of NetBox (v2.1.4) to see if that resolves your issue.

@jvanderaa
Copy link
Contributor Author

Sorry Jeremy, I am at 2.1.4. Something got in my mind that I was a little ways back.
(v2.1.4)

@jeremystretch
Copy link
Member

@vanderaaj Could you please extend the steps needed to recreate this? Be sure to outline the process of creating the custom field first.

@jvanderaa
Copy link
Contributor Author

Do my best.

  1. Created DCIM custom field on the Django admin page as a field selection custom field. I believe that I did that with 2.1.4
  2. Added 3 fields to select (I thought there were only 3 service contracts)
  3. I added a few devices to have the service contract

Then I found about 10 more service contracts
4) Went back into the Django admin console and went to the custom field
5) Added the additional 10 service contracts to the field
6) Created script to change the service contract field based on a spreadsheet with the contract information on it
7) The fields that are showing up duplicate are "Not Covered" and "Product name that starts with N.."

  • The remaining contract fields all start with a custom number

@jeremystretch
Copy link
Member

@vanderaaj You'll need to provide specific values for every field in the reproduction. You'll also need to provide the exact script that you ran; otherwise, we have no idea what was modified.

@jvanderaa
Copy link
Contributor Author

@jeremystretch makes perfect sense to me about wanting the full data, is there a method to get those communicated that isn't all over a Github public page? With this being our contract information, probably best to not have those contract numbers showing up.

I'm almost thinking that it may have been something with adding in additional contracts after adding data. Or else, just an input error on my part. I'm all for getting the data if it will help the community in the future. But if it is just to try to fix one individual user issue, I'm good with deleting and recreating the custom field. I've automated the process of getting each device into that field, so that isn't much work.

@jeremystretch
Copy link
Member

@vanderaaj

is there a method to get those communicated that isn't all over a Github public page?

All development activity is tracked publicly. You'll need to detail the steps needed to recreate the bug using sanitized or fabricated data. Starting up a separate instance of NetBox running a fresh installation is a good idea.

@jvanderaa
Copy link
Contributor Author

All good on the public dev. I thought a previous comment wanted the real live data. One more attempt...

  1. Go to User Account on top right and select drop down to Admin
  2. Click Add under Custom Fields
  3. Create Custom Field as follows:
    a. Object: "dcim > device"
    b. Type: "Selection"
    c. Name: "support_contract"
    d. Label: "Support Contract"
    e. Description: "Support Contract Information"
    f. Required: Unchecked
    g. Is filterable: Checked
    h. Default: Blank
    i. Weight: "100"

Custom Field Choices Set
Value: "NationalCoverage"
Value: "44223355: 8x5xNBD"
Value: "44223355: 24x7x4"

Set approximately 12 devices to the 3rd value, then I found more contracts.

Followed the same process to get into the dcim custom field.

Then added the following options
Value: "202438275: 8x5xNBD"
Value: "202438705: 8x5xNBD"
Value: "202531453: 8x5xNBD"
Value: "84284102: EMER"
Value: "93583721: P2E"
Value: "94283751: EMER"
Value: "94678217: PEA"
Value: "Needs Coverage"

Then I had a CSV file with device, contract and used the API to assign a contract to the device.
Then some devices that have the NationalCoverage contract show up in a query for
devices in Needs Coverage. When going into the device, it shows properly. The
search page just displays incorrectly.

@jeremystretch
Copy link
Member

When going into the device, it shows properly. The search page just displays incorrectly.

Please provide the query you're using to search.

@jvanderaa
Copy link
Contributor Author

Devices -> Devices, Scroll down the right hand search filter to Support Contract custom field drop down. Selecting NationalCoverage and then devices with Needs Coverage show up in the search.

@jeremystretch
Copy link
Member

I think I know what's happening. The PK for the "NationalCoverage" option is 1, and the PK for the "Needs Coverage" option is 11. The query is filtering on ?cf_support_contract=1, which is being evaluated as:

custom_field_values__serialized_value__icontains=1

This matches both serialized values 1 and 11. We need to modify the filter to only match on exact values for select fields.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application and removed awaiting reply labels Oct 20, 2017
@jeremystretch jeremystretch self-assigned this Oct 20, 2017
@jeremystretch jeremystretch changed the title DCIM Custom Field Search - Returning Wrong Info Custom field choice filtering matches multiple choices Oct 20, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants