Skip to content

Commit 804aa5d

Browse files
authored
add UI Action/GlideModalForm - Open New Record and Pass Query code snippet (#257)
* Create code.js * Create readme.md
1 parent 851792a commit 804aa5d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function functionName() { //specify the function name you listed within the UI Action "onClick" field
2+
var tableName = "table_name"; //specify what table the new record should be created on
3+
var dialog = new GlideModalForm('modal_form_title', tableName); //set your modal form title here
4+
dialog.setSysID(-1); //sys_id -1 will open a brand new record
5+
dialog.addParm('sysparm_view', 'view_name'); //optional: you can specify a specific view name here
6+
dialog.addParm('sysparm_view_forced', 'true'); //optional: you can force the view so it overrides
7+
dialog.addParm('sysparm_form_only', 'true'); //optional: you can specify to show the form only, removing related lists from the screen
8+
var sDesc = g_form.getValue('short_description'); //example retrieving the short description on the current record
9+
var query = "short_description=" + sDesc; //example setting the query JavaScript variable to the sDesc JavaScript variable that contains our current record's short description
10+
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
11+
dialog.render(); //displays the modal form to the user
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
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
2+
3+
Within the UI Action settings it's recommended to ensure:
4+
- Active is true
5+
- Either show insert and/or show update is true
6+
- Client is true
7+
- Your appropriate List v2 or V3 compatible checkbox is true
8+
- Onclick contains your function name that matches the function within your Script field -- the code related to this snipped would be: **functionName()**
9+
- 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.

0 commit comments

Comments
 (0)