Capture an existing Large Database view in an Update set

D_8
Tera Contributor

Hi All,

We have a large Database view that is created by Joining Multiple Tables. This database view is created long back and it was not captured in an Update set. Now my requirement is to capture this Database in an Update set and  Move it to our Test Instance. I created an Update set and captured few database view tables and table fields by changing values in fields and changing them back(That way am not making any changes). Thing is I have 8 Database view Tables and 170 Database view Table fields. Its really a pain to capture a Database view in an update set if i do it my way. 

Is there any other way to ease the Process, also after doing some research online, I saw some posts where they described applying an update set which contains a Database view will result in Preview errors for each table/field in the Database view. If am pushing such a large Database view in an update set, wont it result in the same preview errors? 

Any help is greatly appreciated.

1 ACCEPTED SOLUTION

ARG645
Tera Guru
Came across the same problem many months back. We made a UI action called "Force Database view to Update Set". We never encountered the Update set preview Problems whicle moving database views using this UI actions. If you do encounter Preview Errors which says Could not find a table ******* this update requires, Accept the remote Update.
 
Limitations:
  1. This UI Action wont work in Scoped Apps. 

How it Looks: 

find_real_file.png
 
UI Action Cofigureation: 
find_real_file.png
UI Action Code: 
//Push the Database view basic info into the current update set
var updateSet = new GlideUpdateManager2();
updateSet.saveRecord(current);

//Push the Database view tables into current update set
var dbViewTablesList=[];
var dbViewTables = new GlideRecord('sys_db_view_table');
dbViewTables.addQuery('view', current.sys_id);
dbViewTables.query();
while (dbViewTables.next()) 
{
	updateSet.saveRecord(dbViewTables);
	dbViewTablesList.push(dbViewTables.getValue('sys_id')); // To avaoid Nested Glide Query
}

//Push the Database view Tables Fields into current update set
if(dbViewTablesList.length > 0)
	{
		var dbViewTableFields = new GlideRecord('sys_db_view_table_field');
		dbViewTableFields.addQuery('view_table', 'IN', dbViewTablesList.join(','));
		dbViewTableFields.query();
		while (dbViewTableFields.next()) 
		{
			updateSet.saveRecord(dbViewTableFields);
		}
}
 
 

View solution in original post

4 REPLIES 4

ARG645
Tera Guru
Came across the same problem many months back. We made a UI action called "Force Database view to Update Set". We never encountered the Update set preview Problems whicle moving database views using this UI actions. If you do encounter Preview Errors which says Could not find a table ******* this update requires, Accept the remote Update.
 
Limitations:
  1. This UI Action wont work in Scoped Apps. 

How it Looks: 

find_real_file.png
 
UI Action Cofigureation: 
find_real_file.png
UI Action Code: 
//Push the Database view basic info into the current update set
var updateSet = new GlideUpdateManager2();
updateSet.saveRecord(current);

//Push the Database view tables into current update set
var dbViewTablesList=[];
var dbViewTables = new GlideRecord('sys_db_view_table');
dbViewTables.addQuery('view', current.sys_id);
dbViewTables.query();
while (dbViewTables.next()) 
{
	updateSet.saveRecord(dbViewTables);
	dbViewTablesList.push(dbViewTables.getValue('sys_id')); // To avaoid Nested Glide Query
}

//Push the Database view Tables Fields into current update set
if(dbViewTablesList.length > 0)
	{
		var dbViewTableFields = new GlideRecord('sys_db_view_table_field');
		dbViewTableFields.addQuery('view_table', 'IN', dbViewTablesList.join(','));
		dbViewTableFields.query();
		while (dbViewTableFields.next()) 
		{
			updateSet.saveRecord(dbViewTableFields);
		}
}
 
 

D_8
Tera Contributor

Thanks for the suggestions, I will try this and let you know. 

D_8
Tera Contributor

Thank you This solution works great. I just moved my Update set to another instance for testing and did not see any problem. 

Only Problem I saw is that if you click the UI action Multiple times, it will push the same entity into the update set as a customer update making it a duplicate, which may not be a problem at all. This can be used as a Quick and Dirty way to move Database view to update sets.

LuisLopez
Giga Contributor

sys_ui_view_list this is the table where Views are saved, the View can be searched there, selected and using related links, force it to updateset