Closed michaeldcanady closed 3 years ago
You want to change the selected value of a choice field in an alm_hardware object, correct?
The IntegerMap
field is mainly used when working with response data; it validates the field's JSON object and deserializes into a named tuple, holding its value
and display_value
attributes as key
(integer) and value
(string) respectively. Other than that, it behaves like a regular fields.Integer
, including when serializing the payload for an update.
Here is an example of an IntegerMap
field getting updated:
https://github.com/rbw/aiosnow/blob/master/examples/table/update/by_id.py
i.e. it's just like updating a regular fields.Integer
field.
In your case, it'd be something like:
update(<sys_id or Condition>, dict(name_of_choice_field_to_update=1))
async def updateHardware(serviceNow, __sysid__, field, value):
async with HardwareModel(serviceNow, table_name="alm_hardware") as Hardware:
response = await Hardware.update(__sysid__, dict(field = value))
print("Updated status: {}".format(response["install_status"]))
updated code, it still returns: Updated status: <IntegerMapping [key=6, value=In stock]> instead of key = 1
Thank you for the assistance!
nvm, subsequently tests began working. Thank you!
I looked through the documentation, I couldn't find an example of how to update the integerMap values. I am trying to change the selection for a dropdown menu. below is my last (unsuccessful) attempt. Thanks in advance!