syntax_editor_macros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
syntax_editor_macros [03/16/2026 09:06] johnsonjohnsyntax_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("PHI_access_Role");
 +</code>
 +----
 +
 +====doc====
 +<code javascript doc.js>
 +/** 
 +* Description: $0 
 +* Parameters:  
 +* Returns:
 +*/ 
 +</code>
 +----
 +
 +====for====
 +<code javascript for.js>
 +for (var i=0; i< myArray.length; i++) {
 +    //myArray[i]; 
 +}
 +</code>
 +----
 +
 +====info====
 +<code javascript info.js>
 +gs.addInfoMessage(gs.getMessage("$0"));
 +</code>
 +----
 +
 +====vargr====
 +<code javascript vargr.js>
 +var gr = new GlideRecord("$tableName");
 +gr.addQuery("name", "value");
 +gr.query();
 +if (gr.next()) {   
 +}
 +</code>
 +----
 +
 +====vargror====
 +<code javascript vargror.js>
 +var gr = new GlideRecord('$tableName'); 
 +var qc = gr.addQuery('field', 'value1'); 
 +qc.addOrCondition('field', 'value2');
 +gr.query(); 
 +while (gr.next()) {
 + 
 +}
 +</code>
 +----
 +
 =====Client-Side Key Concepts===== =====Client-Side Key Concepts=====
 ====JWJ==== ====JWJ====
Line 6: Line 62:
 //name jwj //name jwj
 //Text //Text
 +//Client-Side Key Concepts
 +//default
 +doc
 +for 
 +info 
 +vargr 
 +vargror
 +
 //Client-Side Key Concepts //Client-Side Key Concepts
 c_GeneratingMessages c_GeneratingMessages
Line 14: Line 78:
 c_ScratchpadDatabaseAccess c_ScratchpadDatabaseAccess
 c_TryBlock c_TryBlock
- +
 //Server-Side Key Concepts //Server-Side Key Concepts
 s_AjaxFunctionDefinition s_AjaxFunctionDefinition
Line 651: Line 715:
  
 ====s_SetRedirectURLFunction==== ====s_SetRedirectURLFunction====
-<code>+<code javascript s_SetRedirectURLFunction.js> 
 +//setRedirectURL(), Debug Now
  
 +//This custom UI Action, "Debug Now" executs "Scheduled Script Execution" scripts (from table "sysauto_script") in the current session.
 +//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, 'script');
 + action.setRedirectURL(current);
 +}
 +catch(e){
 + gs.addInfoMessage(e);
 +}
 </code> </code>
 ---- ----
  
 ====s_TryBlock==== ====s_TryBlock====
-<code>+<code javascript s_TryBlock.js> 
 +//Single LIne Try Catch Block.  Catches errors such as use of undefined functions or methods, or attempting to reference fields of a null object. 
 +try { RunServerSideCustomCode(); } catch(err){ var s = "Error caught by catch block: " + err.toString(); gs.error(s); gs.addErrorMessage(s); }
  
 +function RunServerSideCustomCode(){
 + //Write custom code here...
 + null.MyInvalidFunctionCall();
 +}
 </code> </code>
 ---- ----
  • syntax_editor_macros.1773677217.txt.gz
  • Last modified: 06/28/2026 16:38
  • (external edit)