Created
August 5, 2022 16:48
-
-
Save cmcdevitt/56f51e56cf10713d8d32e5f78a05c755 to your computer and use it in GitHub Desktop.
Save a Database View to an Update Set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Database View[sys_db_view] | |
| Field Name[name] | |
| View Tables [sys_db_view_table] | |
| View [view] -> Database View | |
| View Fields [sys_db_view_table_field] | |
| View Table [view_table] -> View Table | |
| */ | |
| //*** Add view Name Here: | |
| var view_name = 'sn_vul_nvd_di_and_cmdb'; | |
| //*** | |
| var dbv_q = 'name=' + view_name; | |
| var vt_q = 'view='; | |
| var vf_q = 'view_table='; | |
| var dbv = new GlideRecord('sys_db_view'); | |
| var vt = new GlideRecord('sys_db_view_table'); | |
| var vf = new GlideRecord('sys_db_view_table_field'); | |
| var um = new GlideUpdateManager2(); | |
| //Database View | |
| dbv.addEncodedQuery(dbv_q); | |
| dbv.query(); | |
| while(dbv.next()){ | |
| // gs.info("CCCC DBV: " + dbv.name + " " + dbv.sys_id);//Works dbv | |
| um.saveRecord(dbv); | |
| //View table | |
| vt.addEncodedQuery(vt_q + dbv.sys_id); | |
| vt.query(); | |
| while(vt.next()){ | |
| //gs.info("CCCC vt: " + vt.view.getDisplayValue() + " " + vt.sys_id);//Works vt | |
| um.saveRecord(vt); | |
| //View Fields | |
| vf.addEncodedQuery(vf_q + vt.sys_id); | |
| vf.query(); | |
| while(vf.next()){ | |
| //gs.info("CCCC vf: " + vf.view_table.getDisplayValue() + vf.sys_id);//Works vf | |
| um.saveRecord(vf); | |
| } | |
| } | |
| } | |
| gs.info("CCCC finised saving Database View " + dbv.name + " to update set"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment