-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Different default value for 'custom_field' if created via WebUI vs RestAPI #2358
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
Comments
You are aware that you must put the ID of the choice in your request, rather than the value of the choice via the API, right? Maybe post your POST/PUT/PATCH request for easier debugging. At least that's how I remember it to be. |
Yes, I even opened an issue: #1792 |
I'm not sure what you're trying to communicate here, so if there's a question, I would appreciate if you re-phrased it so I can respond appropriately. |
So you said you made a selection custom field. I tried to say that I suspect that you have sent the actual value of the coice via the API. But you must rather send the ID of the choice, not the actual value. (i.e. a number, not a string.) But there is no way (via the API) yet to get the id of a certain choice. That's what the issue which I mentioned is all about. Clearer? |
I probably didn't make this clear in my "Steps to Reproduce" above, but I'm not any setting information via the WebUI or via the API except for the I'm expecting that the Does that clarify the problem I'm reporting it at all? |
I'm not sure that it makes sense to implement this change. Just because a custom field has a default value doesn't necessarily imply that the field should be set on every new instance. The default makes sense for the web UI, since the field is merely pre-populated and the user must confirm (or remove/modify) the field value before submitting the form. When using the API, the user never has this opportunity. |
I'm not sure I agree with that assessment and here's why... If I create a new object in the WebUI that has a As an example, and to demonstrate my use case, our WAN is being upgraded from using a When applied to this scenario, all If the default value is not set via the API, the value will be Does that make sense? |
I see another reason to implement this: When creating an object via API, how does the client know, what the default value is? It simply doesn't and must have this knowledge from somewhere else. Now if the default value changes in Netbox, the client must be updated as well because he would otherwise create objects with the previous default value, as he has no way to receive the new default value. And if the client does not want the default value to be filled in by Netbox, he could still pass |
I'm not sure where this ended up at so I thought I would comment again... Has a decision been made to fix this I really don't like having to keep track of how an object was created (via the I understand there is only so much development that can be done, but the idea of not being deterministic in the creation of new objects is of concern to me. I suppose all I'm asking is for a decision to be made and this issue to be updated to reflect that. |
Just checking in on the status of this issue... I think @cimnine's comment above is as straightforward as it can be:
When setting the default value in the for a |
Environment
This was a feature request in #2159.
I don't recall if it used to work the same way consistently, but I just verified that the result is different if the operation is performed via the WebUI vs the API.
Steps to Reproduce
custom_field
and set it up against anObject
(I chose to apply this todcim > site
).Selection
and setup theCustom Field Choices
appropriately.Choices
.Object
via the WebUI, and it works as expected.Expected Behavior
Have both the WebUI and API operate the same way.
Observed Behavior
The
default
value is correctly applied ONLY if done in the WebUI.The text was updated successfully, but these errors were encountered: