Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| syntax_editor_macros [03/16/2026 09:04] – [s_MailScript] johnsonjohn | syntax_editor_macros [03/16/2026 11:21] (current) – johnsonjohn | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======Syntax Editor Macros====== | ======Syntax Editor Macros====== | ||
| + | ==Also located in downloads== | ||
| ---- | ---- | ||
| + | |||
| + | ====Network Location==== | ||
| + | <code javascript networkLocation.js> | ||
| + | // ADFS with Imprivata MFA should be used to leverage a network location claim | ||
| + | // into SNOW, enabling role based PHI visibility and control. | ||
| + | gs.getSession().getProperty(" | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====doc==== | ||
| + | <code javascript doc.js> | ||
| + | /** | ||
| + | * Description: | ||
| + | * Parameters: | ||
| + | * Returns: | ||
| + | */ | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====for==== | ||
| + | <code javascript for.js> | ||
| + | for (var i=0; i< myArray.length; | ||
| + | // | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====info==== | ||
| + | <code javascript info.js> | ||
| + | gs.addInfoMessage(gs.getMessage(" | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====vargr==== | ||
| + | <code javascript vargr.js> | ||
| + | var gr = new GlideRecord(" | ||
| + | gr.addQuery(" | ||
| + | gr.query(); | ||
| + | if (gr.next()) { | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====vargror==== | ||
| + | <code javascript vargror.js> | ||
| + | var gr = new GlideRecord(' | ||
| + | var qc = gr.addQuery(' | ||
| + | qc.addOrCondition(' | ||
| + | gr.query(); | ||
| + | while (gr.next()) { | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| =====Client-Side Key Concepts===== | =====Client-Side Key Concepts===== | ||
| ====JWJ==== | ====JWJ==== | ||
| Line 6: | Line 62: | ||
| //name jwj | //name jwj | ||
| //Text | //Text | ||
| + | // | ||
| + | //default | ||
| + | doc | ||
| + | for | ||
| + | info | ||
| + | vargr | ||
| + | vargror | ||
| + | |||
| // | // | ||
| c_GeneratingMessages | c_GeneratingMessages | ||
| Line 14: | Line 78: | ||
| c_ScratchpadDatabaseAccess | c_ScratchpadDatabaseAccess | ||
| c_TryBlock | c_TryBlock | ||
| - | + | ||
| // | // | ||
| s_AjaxFunctionDefinition | s_AjaxFunctionDefinition | ||
| Line 593: | Line 657: | ||
| template.print(sAnchorTag); | template.print(sAnchorTag); | ||
| })(current, template, email, email_action, | })(current, template, email, email_action, | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ====s_Object==== | ||
| + | <code javascript s_Object.js> | ||
| + | //object, property definition, function definition, stringify(), | ||
| + | // | ||
| + | |||
| + | //An object is a built-in data type for storing properties (key-value pairs). | ||
| + | //Data inside an object is unordered, and the values can be of any type. | ||
| + | var apple ={ | ||
| + | color: " | ||
| + | family: " | ||
| + | price: " | ||
| + | method1: function(arg1, | ||
| + | return arg1 + arg2 + this.color; | ||
| + | } | ||
| + | }; | ||
| + | |||
| + | gs.addInfoMessage(JSON.stringify(apple)); | ||
| + | gs.addInfoMessage(" | ||
| + | gs.addInfoMessage(' | ||
| + | if (apple.bogusKey) | ||
| + | gs.addInfoMessage(apple.bogusKey); | ||
| + | gs.addInfoMessage(" | ||
| + | |||
| + | for (var appleKey in apple){ | ||
| + | gs.addInfoMessage(appleKey + " : " + apple[appleKey]); | ||
| + | } | ||
| + | gs.addInfoMessage(" | ||
| + | gs.addInfoMessage( apple.method1(5, | ||
| + | |||
| + | //Creating an object from a string. | ||
| + | var sObject = '{ " | ||
| + | var myObject = JSON.parse(sObject); | ||
| + | gs.addInfoMessage(" | ||
| + | for (var myObjectKey in myObject){ | ||
| + | gs.addInfoMessage(myObjectKey + " : " + myObject[myObjectKey]); | ||
| + | } | ||
| </ | </ | ||
| ---- | ---- | ||
| ====s_ScratchpadPopulation==== | ====s_ScratchpadPopulation==== | ||
| - | < | + | < |
| + | // | ||
| + | //Since client side AJAX code may be slow as it involves asynchronous round trips to the server, a special object called g_scratchpad may be used instead. | ||
| + | //Any " | ||
| + | //Context: Business Rule of type " | ||
| + | |||
| + | //Populate the scratchpad from server side code… | ||
| + | (function executeRule(current, | ||
| + | g_scratchpad.MyOwnVariable = " | ||
| + | })(current, previous); | ||
| </ | </ | ||
| ---- | ---- | ||
| ====s_SetRedirectURLFunction==== | ====s_SetRedirectURLFunction==== | ||
| - | < | + | < |
| + | // | ||
| + | //This custom UI Action, "Debug Now" executs " | ||
| + | //Execution in the current session allows the script debugger (and breakpoints) to be used, and lets you see client side messages such as infoMessages. | ||
| + | try{ | ||
| + | var evaluator = new GlideScopedEvaluator(); | ||
| + | evaluator.evaluateScript(current, | ||
| + | action.setRedirectURL(current); | ||
| + | } | ||
| + | catch(e){ | ||
| + | gs.addInfoMessage(e); | ||
| + | } | ||
| </ | </ | ||
| ---- | ---- | ||
| ====s_TryBlock==== | ====s_TryBlock==== | ||
| - | < | + | < |
| + | //Single LIne Try Catch Block. | ||
| + | try { RunServerSideCustomCode(); | ||
| + | function RunServerSideCustomCode(){ | ||
| + | //Write custom code here... | ||
| + | null.MyInvalidFunctionCall(); | ||
| + | } | ||
| </ | </ | ||
| ---- | ---- | ||