ServiceNow / PySNC

Python API for ServiceNow
MIT License
91 stars 25 forks source link

Add `link` attribute to GlideElement when exists. #116

Open andrewduckett opened 3 weeks ago

andrewduckett commented 3 weeks ago

I'd like to include the link attribute in GlideElement when it exists to know if/when an element of a record is a link to another record. Some elements come with an additional attribute, link that points at the specific record.

I did check out the guess_is_sys_id which is usually enough to tell if it's a sys_id but would prefer to use the returned field when available.

I took a quick look to see what this would take, minimally something like:

  1. the base API would need to make the sysparm_exclude_reference_link param configurable. The default value should probably still be false so a quick check to see if it was set is probably enough. https://github.com/ServiceNow/PySNC/blob/1.1.8/pysnc/client.py#L151

  2. the GlideElement would need to accept an optional link when a dict is provided. Optionally an additional kwarg could be included but this might cause more grief for existing users. https://github.com/ServiceNow/PySNC/blob/1.1.8/pysnc/record.py#L32-L36

  3. It might be worth adding some type of getter to the GlideElement as well, again, if it's not going to impact users. Otherwise it looks like it would be included in serialize so that may be sufficient.

vetsin commented 3 weeks ago

I think this could be relatively easily supported, and I agree with your assessment. Though the link attribute via API is 'new' to me as in I don't know/remember it so I'd have to look a little, assuming you weren't just going to send a PR

andrewduckett commented 3 weeks ago

@vetsin I'm happy to open a PR; if you'd prefer to tackle it yourself just let me know how i can support.