ui_actions
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ui_actions [12/30/2024 06:57] – created johnsonjohn | ui_actions [12/31/2025 05:42] (current) – removed johnsonjohn | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | =====UI ACTIONS===== | ||
| - | ---- | ||
| - | ====Find References ==== | ||
| - | < | ||
| - | /* | ||
| - | JWJ0215 2021 DO NOT RUN IN PROD DURING WORK HOURS | ||
| - | #### This is a UI Action | ||
| - | Name: Find Record References | ||
| - | Table: Global | ||
| - | Order: 500 | ||
| - | Action name: find_references | ||
| - | Show insert/Show update: False/True | ||
| - | Form link: True | ||
| - | Client: True | ||
| - | Hint: Find and display all tables and records that reference this record | ||
| - | OnClick: confirmFindReferences() | ||
| - | Condition: gs.hasRole(' | ||
| - | */ | ||
| - | |||
| - | |||
| - | // | ||
| - | function confirmFindReferences() { | ||
| - | if (confirm(' | ||
| - | return false; //Abort submission | ||
| - | } | ||
| - | //Call the UI Action and skip the ' | ||
| - | gsftSubmit(null, | ||
| - | } | ||
| - | |||
| - | //Code that runs without ' | ||
| - | //Ensure call to server-side function with no browser errors | ||
| - | if (typeof window == ' | ||
| - | findReferences(); | ||
| - | |||
| - | // | ||
| - | function findReferences() { | ||
| - | var msg = '< | ||
| - | var refTable = new TableUtils(current.getTableName()).getTables(); | ||
| - | gs.include(" | ||
| - | refTable = j2js(refTable).join(); | ||
| - | var refRecordID = current.sys_id; | ||
| - | //Query dictionary table for reference, document_id, | ||
| - | var dict = new GlideRecord(' | ||
| - | dict.addQuery(' | ||
| - | //Do not query audit and log fields | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.addQuery(' | ||
| - | dict.orderBy(' | ||
| - | dict.orderBy(' | ||
| - | dict.query(); | ||
| - | while (dict.next()) { | ||
| - | var tblName = dict.name.toString(); | ||
| - | // Skip tables used for Table Rotation | ||
| - | var gr = new GlideRecord(" | ||
| - | gr.addQuery(" | ||
| - | gr.addQuery(" | ||
| - | gr.query(); | ||
| - | if (!gr.hasNext()) { | ||
| - | var recMessage = ' records found'; | ||
| - | var filterOperator = ' | ||
| - | var refType = dict.internal_type; | ||
| - | if (refType == ' | ||
| - | filterOperator = ' | ||
| - | } | ||
| - | |||
| - | //Query each table for matching records | ||
| - | var rec = new GlideRecord(tblName); | ||
| - | if (refType == ' | ||
| - | rec.addQuery(dict.element, | ||
| - | } else { | ||
| - | rec.addQuery(dict.element, | ||
| - | } | ||
| - | rec.query(); | ||
| - | if (rec.getRowCount() == 1) { | ||
| - | recMessage = ' record found'; | ||
| - | } | ||
| - | if (rec.getRowCount() > 0) { | ||
| - | //Display table/ | ||
| - | msg = msg + '< | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | |||
| - | //Query for workflow variable values | ||
| - | tblName = ' | ||
| - | var vVal = new GlideRecord(tblName); | ||
| - | vVal.addQuery(' | ||
| - | vVal.query(); | ||
| - | if (vVal.getRowCount() == 1) { | ||
| - | recMessage = ' record found'; | ||
| - | } | ||
| - | |||
| - | if (vVal.getRowCount() > 0) { | ||
| - | //Display table/ | ||
| - | msg = msg + '< | ||
| - | } | ||
| - | |||
| - | gs.addInfoMessage(msg); | ||
| - | action.setRedirectURL(current); | ||
| - | } | ||
| - | </ | ||
| - | ---- | ||
ui_actions.1735570657.txt.gz · Last modified: by johnsonjohn
