Skip to content
This repository has been 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

Open
dfields186 opened this issue Oct 29, 2019 · 0 comments

Comments

@dfields186
Copy link

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")
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant