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

Exception when using SubIssueType picklist #78

Open
bkramCorsica opened this issue Feb 12, 2020 · 9 comments
Open

Exception when using SubIssueType picklist #78

bkramCorsica opened this issue Feb 12, 2020 · 9 comments

Comments

@bkramCorsica
Copy link

bkramCorsica commented Feb 12, 2020

OS: Windows 10 Enterprise
Python: 3.8.1 x64
Version: atws-0.5.5

Running a SubIssueType picklist lookup such as:
autotask_connection.picklist['Ticket']['SubIssueType']["SIEM"]["Review"]
Raises a KeyError exception:
('label not found in index', 'Label', 'Review')
Despite the fact that they are valid issue and subissue types.

The problem appears to be with

def _condition(self, picklist_value):
return (picklist_value.parentValue == self.parent_item_value
and is_active(picklist_value))

Where self.parent_item_value is an integer, but picklist_value.parentValue is a suds Text object causing the condition to return false when it shouldn't

@rocky-holms
Copy link

If we can get the picklist mitigated in the main repo that would be great. If not this may be a fork off of to fix.

@MattParr
Copy link
Owner

I've clearly written this part of the lookup to meet a business need on my side. The picklist value for both parent and child must be active. It looks like you have inactive values.

I'd be happy to accept a pull request that contained a switch to the picklist.. probably at this level:

child_field_picklist = autotask_connection.picklist['Ticket']['SubIssueType']
child_field_picklist.ignore_inactive = False

but I'd also accept:

autotask_connection.picklist.ignore_inactive = False

or, as a stretch goal. both.

@MattParr
Copy link
Owner

or, if it is active, and it's failing a match because parentValue seems to be a text value because of
issue: #53 where the fix was not quite wide enough.

I'll try to get a fixed version out soon.

I'm thinking:

def get_field_picklist(field_name, field_info):
field_picklist = find('Name',
field_name,
field_info.Field)
# Convert Picklist Values to int
# See issue: https://github.com/MattParr/python-atws/issues/53
for item in field_picklist.PicklistValues:
for picklist_value in item[1]:
setattr(picklist_value, 'Value', int(picklist_value.Value))
return field_picklist

becomes:

def get_field_picklist(field_name, field_info):
    field_picklist = find('Name', 
                          field_name, 
                          field_info.Field)
    # Convert Picklist Values to int
    # See issue: https://github.com/MattParr/python-atws/issues/53
    for item in field_picklist.PicklistValues:
        for picklist_value in item[1]:
            setattr(picklist_value, 'Value', int(picklist_value.Value))
            if picklist_value.parentValue:
                setattr(picklist_value, 'parentValue', 
                        int(picklist_value.parentValue))

    return field_picklist

@rocky-holms
Copy link

That would be great. Things have been pretty crazy lately, but i'll look for that change.

@mtingers
Copy link
Contributor

mtingers commented Jul 8, 2020

I recently ran into this issue too. @MattParr I have been testing with your proposed change and haven't had any issues yet and can't think of anything that it would break.

@mtingers
Copy link
Contributor

In some cases,

if picklist_value.parentValue:

will throw an exception: 'PickListValue' object has no attribute 'parentValue'.

Instead, this has not caused issues for me yet:

if getattr(picklist_value, 'parentValue', None):

@natchu
Copy link

natchu commented Jun 1, 2021

Is this fix something that is going to be added in soon?

@MattParr
Copy link
Owner

MattParr commented Jun 1, 2021

Hi @natchu
I'm sorry you are running into this problem. I had not realised that people were still using this library.
The company I worked for left Autotask, but I still had access to an archived instance.
I maintained it for two years after I moved away from Autotask, but then they put out a REST API and I rested.
Now (4 years later) I do not have access to Autotask at all!
I can't really make the change and test it. I'd be happy to accept a pull request if it's been tested.

@natchu
Copy link

natchu commented Jun 24, 2021

@MattParr Sure, I can create a fix for the same and raise a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants