The CreatorCon Call for Content is officially open! Get started here.

What tables are used to hold a view on a form

Dave65
Tera Contributor

I am trying to programmatically create the Default view on a form  if it doesn't already have the view defined.
I know there are many tables involved and I haven't been able to find all of the tables involved.

sys_ui_related_list - This table holds all of the related lists on a form. If it does not have the table/view combination I need, I need to add the view to the form.
sys_ui_view - This table holds a list of the views in the system and what forms/tables each is associated with. Simply adding the view to this table does not add it to the form for a table.

 

grNewView = new GlideRecord('sys_ui_view');
grNewView.initialize();
grNewView.setValue('name', viewName.toLowerCase().replace(/ /g, "_"));
grNewView.setValue('title', viewName);
grNewView.setValue('sys_scope', 'Global');
grNewView.insert();

 

Form [sys_ui_form] - Holds all of the Forms in the system and the sections for each form as well as the table and view it is associated with.

 

grViewUI = new GlideRecord('sys_ui_form');
grViewUI.initialize();
grViewUI.setValue('view', 'data_export_view');
grViewUI.setValue('name', 'u_data_export_repository');
grViewUI.setValue('sys_scope', 'Global');
grViewUI.insert();

 

 
Form Section [sys_ui_form_section] - Defines the sections associated with a table and the form they are on.
I have only tried to manually create a section on this table using the normal method:
Dave65_0-1669759330474.png

 

Has anyone ever added a view dynamically via Java Script to a table/form? I could really use a hand with this.

 

Thank you for your help,

Dave

2 REPLIES 2

Community Alums
Not applicable

Hi Dave,

as far as I remember it (was long time ago to be frank), I think I used something OOB, kind of hidden/undocumented Glide class.

In my "cheat notes" I found this:

TableEditorAjaxProcessor - script include name

GlideSysForm.generateDefaultForm(tableName); - what I used for that.

 

Can you give it a try and let me know if I am correct ?

 

P.S. For related list - check script include SysList

Cheers,

Joro

Dave65
Tera Contributor

Good Morning Joro
I got sidetracked and have not had a chance to test your suggestions although, I did look for documentation and found none.
My partner did find a solution to our real issue which was being able to add a related list by using the following:

var table = new GlideTableHierarchy(_activeTable);
var tableTree = table.getTables();

You can look this up in the Scoped Server APIs.

 

Thank you for your time!

 

Dave