-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support for customFields or configuration questions #26
Comments
Hey @djBirdman, I know this question has been out here for a bit, but wanted to check in to see if you still have the issue and if you could clarify better what you're looking for, not 100% sure from reading your original note. |
In terms of the issue I was trying to solve, we got around it by using the built-in 'ipAddress' field and working out a way to use a custom Hosted API pod in the configurations page rather than a hyperlink in a custom field. What we are looking for is supporting custom fields in any part of ConnectWise, or specifically questions fields under configurations. (I've lumped them together, because they are both lists of dictionaries) i.e. just like I can get all configurations for a company if I know the company ID
we'd like to be able to do the same for custom fields or questions, e.g. for routers where we record the external IP address in a question, it might look like
Similarly, for setting fields where we would use
we might update with
For reference, this is how things look when we print() a returned configuration
|
Since connectpyse is a very light wrapper around the Manage REST API, anything that the REST API supports should be workable using connectpyse. This is true of configuration questions and custom fields. Most of this is based on what I pulled from the official Manage docs here. The Given a configuration item with the following question:
You can query for this config item using this URL: I don't have an interpreter in front of me, but I believe the above can be done with connectpyse like this:
The same should hold true for custom fields (using the |
Ah, thanks for that - I had missed the query string parameters section of that CW docs page when reading previously. I've tested connectpyse and it needs to be
(My python fu isn't strong, but interestingly there are no errors when using the camel case name. The API definitely ignores it though) I need to do further testing for updating custom fields/questions, but if I understand the 'Patch' section in the CW docs then we would need to update the object locally and then update the whole object via API, i.e. for configurations using |
Right, it's been too long, but finally got around to looking into this...and confirming that can successfully update questions and custom fields. The CW API states that when updating fields "When working with custom fields, you must pass the entire array of custom fields.", and the same holds for questions under configuration. (The method below works for customFields, except of course updating 'value' instead of 'answer') To update the question on an answer, copy the questions array locally, update the answer field in that copy and pass the array as the value in update_configuration()
|
I'm wondering if there is support for custom fields, or in particular for what I'm working on right now configuration questions?
If I'm understanding things correctly, these are both presented as lists of dictionaries, compared to things like company and site that are presenting as a dictionary and where the "sub-attributes" are used.
For example printing out custom fields shows:
customFields: [{'id': 7, 'caption': 'Link', 'type': 'Hyperlink', 'entryMethod': 'EntryField', 'numberOfDecimals': 0, 'value': 'https://www.example.net/1234}]
... and configuration questions similarly as:
questions: [{'answerId': 1014, 'questionId': 502, 'question': 'What is the IP address?', 'answer': '192.168.1.66', 'sequenceNumber': 1.0, 'numberOfDecimals': 0, 'fieldType': 'IPAddress', 'requiredFlag': False}]
I thought it might work with something along the lines of: configurationsApi.update_configuration(configId, 'customFields/id=7', 'https://www.example.net/1235')
...or configurationsApi.update_configuration(configId, 'questions/questionId=502', '192.168.1.65')
NB: I have tested the update method with sub-attributes and it works perfectly - in case this is useful for others or worth documenting: configurationsApi.update_configuration(configId, 'site/id', 1078)
Also useful in the main readme might be how multiple conditions can be used e.g. configurationsApi.conditions = f'type/id=100 AND name contains "{searchString}"' (also noting that the CW API expects search strings to be enclosed with double quotes)
The text was updated successfully, but these errors were encountered: