PySNC icon indicating copy to clipboard operation
PySNC copied to clipboard

Add `link` attribute to GlideElement when exists.

Open andrewduckett opened this issue 1 year ago • 2 comments

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.

andrewduckett avatar Aug 27 '24 20:08 andrewduckett

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

vetsin avatar Aug 27 '24 21:08 vetsin

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

andrewduckett avatar Aug 27 '24 21:08 andrewduckett