Closed insomniacc closed 1 year ago
Added: Get-SNOWSCRequestedItem Added: Get-SNOWSCRequest Added: Get-SNOWSCTask Added: Get-SNOWIncident
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.
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.
Function builder enhancement #24
Completed initial functionality of function builder.
Once #7 is completed, the most common table functions should be added for basic use. Incident Request RequestedItem Task Approvals Change