Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional common table functions #9

Closed
insomniacc opened this issue Mar 8, 2023 · 5 comments
Closed

Additional common table functions #9

insomniacc opened this issue Mar 8, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@insomniacc
Copy link
Owner

insomniacc commented Mar 8, 2023

Once #7 is completed, the most common table functions should be added for basic use.
Incident
Request
RequestedItem
Task
Approvals
Change

@insomniacc insomniacc added the enhancement New feature or request label Mar 8, 2023
@insomniacc insomniacc added this to the v0.0.1 milestone Mar 8, 2023
@insomniacc insomniacc self-assigned this Mar 8, 2023
@insomniacc
Copy link
Owner Author

insomniacc commented Mar 12, 2023

Added: Get-SNOWSCRequestedItem
Added: Get-SNOWSCRequest
Added: Get-SNOWSCTask
Added: Get-SNOWIncident

@insomniacc
Copy link
Owner Author

insomniacc commented Mar 13, 2023

Gone down a bit of rabbit hole with this one. Figured I'd make a 'functionBuilder', since the underlying framework is set and the process is the same to create new TABLE CRUD functions.

I've come up with a script that, given the input of a table name and function name, it will pull all the associated fields for that table from sys_dictionary & their types. It will use the boilerplate for the template CRUD functions and just fill in the parameter set based on those fields. Then spit out a function.ps1 file in the correct folder & add it to the manifest.

Only looking at the GET function builder at the moment...
There's obviously a LOT of types in snow, so rather than over engineering this I'm keeping it simple for now.
booleans get translated correctly, the rest are strings
date/time fields are ignored (since the params on a get are used for exact matches, there's no way to use an operator other than in a query, so it's mostly unnecessary to include these).

I've noticed two issues so far, some fields are not listed in my method to pull from sys_dictionary, not sure if this is to do with classes/extended from tables etc.
Also, reference fields will ONLY accept a sys_id at present and not a string (displayvalue).
It seems that when using sysparm_query in the call, it only takes literal values not display values with the = operator, omitting this and just using key value pairs allows for display values.

@insomniacc
Copy link
Owner Author

insomniacc commented Mar 13, 2023

I've fixed the issue with sysparm_query and literal values.
On the topic of missing columns, it's because the tables are extended from other tables, the builder will need to recurse up through them.

Currently I'm looking up all sys_dictionary definitions based on the table name.
I'll need to lookup the table in sys_db_object first and then recurse through the extends table attribute to get all table names prior to getting fields.

@insomniacc
Copy link
Owner Author

Function builder enhancement #24

insomniacc added a commit that referenced this issue Mar 13, 2023
@insomniacc
Copy link
Owner Author

Completed initial functionality of function builder.

  • Added New/Set-SNOWChangeRequest
  • Added New/Set-SNOWIncident
  • Added New/Set-SNOWSCRequest
  • Added New/Set-SNOWSCRequestedItem
  • Added New/Set-SNOWSCTask
  • Added Get/Set/New-SNOWTask

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant