Skip to content
This repository was archived by the owner on Jan 12, 2021. It is now read-only.
This repository was archived by the owner on Jan 12, 2021. It is now read-only.

Querying Partial Info with fetch_all or fetch_one using "Contains" or "LIKE" #43

@dfields186

Description

@dfields186

I'm trying to figure out how to query a table in servicenow using either the "fetch_all" or "fetch_one" methods and use a "contains" like construct so that if I query for a street address I can just put in an address like '1234 Some Street' or I could I put in '1234 Some' and I would all the records with street names matching '1234 Some' - in case there were records with the abbreviation 'St' or 'Str', etc.

partial code listing below:

import pprint
sn_cmn_location = ServiceNow.Base(sn_conn)
sn_cmn_location.table = "cmn_location.do"
street = input("Street Address: ")
results = sn_cmn_location.fetch_all({'street': street})
if len(results['records']) > 0:
print("Records found: " + str(len(results['records'])))

    for record in results['records']:
        try:
            if record['__status'] == 'success':
                print("Incident Location: " + record['name'])
                pprint.pprint(record)

        except KeyError:
            print("Record not Found")
else:
    print("Zero records found")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions