ansible-collections / servicenow.itsm

Ansible Collection for ServiceNow ITSM
GNU General Public License v3.0
89 stars 78 forks source link

Add inventory plugin option: return_display_value #317

Open miyuk opened 6 months ago

miyuk commented 6 months ago
SUMMARY

When inventory plugin query choice field, it return value as human readable label. However, label value is not useful for ansible inventory.

I want to add options for select value format.

I already make sure resolve it when snow_query.sysparm_display_value sets to False.

So, I want to add option return_display_value, and add parameter to fetch_records function

However, I coudn't investigate other column fields.

ISSUE TYPE
COMPONENT NAME

servicenow.itsm.now

ADDITIONAL INFORMATION

below image is configured in ServiceNow column choice field. image

If return_display_value is true, return label, else return value.

---
plugin: servicenow.itsm.now
columns:
  - u_environment
return_display_value: true or false # <- add option
# `Procution A` when true
# `prod_a` when false
tupyy commented 6 months ago

hello @miyuk Is the column Environment custom?

miyuk commented 6 months ago

hi, @tuppy Yes, Environment column is customed one of cmdb_ci_server table

tupyy commented 6 months ago

Can you give me a hint on how can I create it?

miyuk commented 6 months ago

@tupyy

  1. access servicenow developer instance(devxxxx.service-now.com)
  2. access cmdb_ci_server table
  3. click left menu and go to Configure > Form Builder
  4. Add filed at Add a field in the table on left tab
  5. Add filed to table column by drag and drop
tupyy commented 6 months ago

@miyuk I'm ok to add the variable but I'll keep the same name as in SNow: sysparm_display_value.

@mhjacks @Akasurde some context: Currently, the inventory plugin embeds this variable sysparm_display_value and sets it to true. It can be overwritten with sysparm_query.sysparm_display_value but it feels like a hack. What I propose is to move it into the plugin variables like sysparm_limit. WDYT?