Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions UI Actions/GlideModalForm - Open New Record and Pass Query/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function functionName() { //specify the function name you listed within the UI Action "onClick" field
var tableName = "table_name"; //specify what table the new record should be created on
var dialog = new GlideModalForm('modal_form_title', tableName); //set your modal form title here
dialog.setSysID(-1); //sys_id -1 will open a brand new record
dialog.addParm('sysparm_view', 'view_name'); //optional: you can specify a specific view name here
dialog.addParm('sysparm_view_forced', 'true'); //optional: you can force the view so it overrides
dialog.addParm('sysparm_form_only', 'true'); //optional: you can specify to show the form only, removing related lists from the screen
var sDesc = g_form.getValue('short_description'); //example retrieving the short description on the current record
var query = "short_description=" + sDesc; //example setting the query JavaScript variable to the sDesc JavaScript variable that contains our current record's short description
dialog.addParm('sysparm_query', query); //sets the query to the JavaScript variable from the line above, this will populate the related field(s) on the new form with the values specified
dialog.render(); //displays the modal form to the user
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This is an example of using the GlideModalForm API to open a brand new record on a specific table, passing along query parameters to it to assist with loading filling out the form

Within the UI Action settings it's recommended to ensure:
- Active is true
- Either show insert and/or show update is true
- Client is true
- Your appropriate List v2 or V3 compatible checkbox is true
- Onclick contains your function name that matches the function within your Script field -- the code related to this snipped would be: **functionName()**
- Set true to however you wish to display this UI Action to the user; whether that's via Form button, Form context menu, Form link, etc.