servicenow.itsm icon indicating copy to clipboard operation
servicenow.itsm copied to clipboard

Add value key to return data

Open valkiriaaquatica opened this issue 1 year ago • 4 comments

SUMMARY

When receiving objetct that contain a dictionary with display_value, link and value, just the display_value was returned, now it returns also the value that is the sys_id.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

now.py

ADDITIONAL INFORMATION

In relation with this issue https://github.com/ansible-collections/servicenow.itsm/issues/317 , with the actual plugin inventory it just returns the display_value of objects, with the change the value (the sys_id) is also returned. This has been usefull to me when working with server inventories I wanted to get the email associated from the user (columns assigned_to and owneed_by) but just the name was returned so I couldn't resolve it to email (excepto for using LDAP modules), so with the change now the sys_id of the Persona (object) is returned so I can use the api_info module fetching with the sys_id and get the data like in my case the emaill

Before with one example

    "_meta": {
        "hostvars": {
            "Poller": {
                "assigned_to": "Mathuew",
                "owned_by": "Steven",
                "u_server_id": "i-123456"
            }
        }
    },
plugin: servicenow.itsm.now
table: cmdb_ci_server
sysparm_query: 'name=Poller'
columns: assigned_to, owned_by, u_server_id

AFTER

    "_meta": {
        "hostvars": {
            "Poller": {
                "assigned_to": "Mathuew",
                "assigned_to_value": "123456789101123145",
                "owned_by": "Steven",
                "owned_by_value": "987654321",
                "u_server_id": "i-123456"
            }
        }
    },

Inventory adding the show_values argument

plugin: servicenow.itsm.now
table: cmdb_ci_server
sysparm_query: 'name=Poller'
columns: assigned_to, owned_by, u_server_id
show_values: true

valkiriaaquatica avatar May 20 '24 10:05 valkiriaaquatica

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/6fa2060a0d914b2285021ea9ff5c169f

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 3m 50s :heavy_check_mark: build-ansible-collection SUCCESS in 8m 23s

Hi, I'am checking the CI errors and there is an error in black format in test_service_catalog_info.py which is not in my PR, shoudl i fix it? The other error in unit _"AttributeError: 'InventoryModule' object has no attribute 'load_name'" which in a first seen I do no know how to fix it

Thanks in advance for the help

valkiriaaquatica avatar May 20 '24 11:05 valkiriaaquatica

Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/1080d90151ea496dac96ec3d22ed0314

:heavy_check_mark: ansible-galaxy-importer SUCCESS in 5m 31s :heavy_check_mark: build-ansible-collection SUCCESS in 7m 37s

Hi, I'am checking the CI errors and there is an error in black format in test_service_catalog_info.py which is not in my PR, shoudl i fix it?

Thanks in advance for the help

No. the lint is broken. it's checks out the main branch just lint your code with the black version in the workflow.

tupyy avatar May 21 '24 15:05 tupyy