From 9e9aeb6f335a2e6ebd99204a650b8fdfd8360227 Mon Sep 17 00:00:00 2001 From: Allen A <69802495+allenandreas@users.noreply.github.com> Date: Wed, 13 Oct 2021 12:46:51 -0400 Subject: [PATCH 1/2] Create code.js --- .../code.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 UI Actions/GlideModalForm - Open New Record and Pass Query/code.js diff --git a/UI Actions/GlideModalForm - Open New Record and Pass Query/code.js b/UI Actions/GlideModalForm - Open New Record and Pass Query/code.js new file mode 100644 index 0000000000..32c0e36d3d --- /dev/null +++ b/UI Actions/GlideModalForm - Open New Record and Pass Query/code.js @@ -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 +} From af32d9946eb3fc9118fe0995cdb45ba37d64ba30 Mon Sep 17 00:00:00 2001 From: Allen A <69802495+allenandreas@users.noreply.github.com> Date: Wed, 13 Oct 2021 12:51:36 -0400 Subject: [PATCH 2/2] Create readme.md --- .../readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 UI Actions/GlideModalForm - Open New Record and Pass Query/readme.md diff --git a/UI Actions/GlideModalForm - Open New Record and Pass Query/readme.md b/UI Actions/GlideModalForm - Open New Record and Pass Query/readme.md new file mode 100644 index 0000000000..edaac28229 --- /dev/null +++ b/UI Actions/GlideModalForm - Open New Record and Pass Query/readme.md @@ -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.