User Tools

Site Tools


syntax_editor_macros

Differences

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

Link to this comparison view

Next revision
Previous revision
syntax_editor_macros [01/07/2025 13:00] – created johnsonjohnsyntax_editor_macros [01/07/2025 13:16] (current) johnsonjohn
Line 1: Line 1:
-ttt+======Syntax Editor Macros====== 
 +---- 
 +=====Client-Side Key Concepts===== 
 +====JWJ==== 
 +<code> 
 +//name jwj 
 +//Text 
 +//Client-Side Key Concepts 
 +c_GeneratingMessages 
 +c_GlideAjaxMethod 
 +c_GlideRecordDatabaseAccess 
 +c_GlideRecordGetReferenceDatabaseAccess 
 +c_ReusableScript 
 +c_ScratchpadDatabaseAccess 
 +c_TryBlock 
 +  
 +//Server-Side Key Concepts 
 +s_AjaxFunctionDefinition 
 +s_CurrentAndPreviousGlideRecordObjects 
 +s_EventDefinitionAndTriggering 
 +s_ExcelFileProcessing 
 +s_GeneratingMessages 
 +s_GlideRecordDatabaseAccess 
 +s_GlideRecordDatabaseInsert 
 +s_JavaScriptArrays 
 +s_JavaScriptObjects 
 +s_LibraryClassAndFunctionUsage 
 +s_LibraryClassDefinition 
 +s_LibraryFunctionDefinition 
 +s_MailScript 
 +s_ScratchpadPopulation 
 +s_SetRedirectURLFunction 
 +s_TryBlock 
 +</code> 
 +---- 
 + 
 +====c_GeneratingMessages==== 
 +<code> 
 +//text 
 +//alert(), addInfoMessage(), showFieldMsg(), jslog(), addDecoration() 
 +  
 +//Context: Most client side code. 
 +  
 +//Ways to generate messages from client side code: 
 +//Use the alert() function to show a prominent and blocking modal dialog which must be explicitly dismissed for execution to continue. 
 +//Display a message to the user from Client code using g_form.addInfoMessage() or g_form.addErrorMessage() 
 +//Use g_form.addDecoration() to show a small graphic symbol by a form field label.  A mouse-over popup hint may be included, and a color may be specified. 
 +//Use g_form.flash() to display a flashing colored background box behind a form field label. 
 +//Use the confirm() function to display a modal popup dialog to get a response (OK or Cancel) from the user before continuing execution. 
 +//Use the jslog() function to write a message to the web browser console. 
 +function onLoad() { 
 +                alert("My Alert Message"); //Modal dialog with OK button.  
 +                 
 +                g_form.addErrorMessage("My Error Message"); //Wide message at top of form in Red. 
 +                g_form.addInfoMessage("My Info Message"); //Wide message at top of form in Blue. 
 +                 
 +                g_form.showFieldMsg("name", "My Field Message"); //Message UNDERNEATH field.  Same width as field.  Displayed in blue. 
 +                g_form.showFieldMsg("name", "My Field Message - info", "info"); //Again, message UNDERNEATH field.  Same width as field.  Displayed in blue. 
 +                g_form.showFieldMsg("name", "My Field Message - error", "error"); //Message UNDERNEATH field.  Same width as field.  Displayed in red. 
 +                g_form.showFieldMsg("name", "My Field Message - warning", "warning"); //Message UNDERNEATH field.  Same width as field.  Displayed in orange. 
 +                 
 +                jslog("My jslog Log"); //Sends a message to the web browser console log seen using F12. 
 +  
 +                g_form.addDecoration("name", "icon-user", "This icon is called icon-user"); //Icon to the left of field. 
 +                g_form.addDecoration("name", "icon-tree", "This icon is called icon-tree", "color-green"); 
 +                g_form.addDecoration("name", "icon-lightbulb", "This icon is called  icon-lightbulb", "color-red"); 
 +                 
 +                g_form.flash("name", "#AAFACD", -4); //Yellow highlight bar over field for 4 seconds. 
 +  
 +                var vResult = confirm("My Confirmation Message") ? "User clicked OK" : "User clicked Cancel"; //Modal dialog with 2 buttons. 
 +                g_form.addInfoMessage(vResult); //Wide message at top of form in Blue. 
 +
 +</code> 
 +---- 
 + 
 +====c_GlideAjaxMethod==== 
 +<code> 
 +//text 
 +//GlideAjax, addParam(), getXMLAnswer 
 +  
 +//From client side code, to invoke server side code asynchronously, instantiate a custom GlideAjax object. 
 +//Use the addParam() function, and by convention, the parameter named "sysparm_name" to specify which server side function to invoke. 
 +//Additional arbitrary parameters may also be specified with addParam(); In this example "sysparm_Prefix"
 +//Use getXMLAnswer() to invoke the server-side function and specify a callback function; in this example "finishClientSideWorkONE"
 +//Use a direct parameter in your callback function to make use of data returned by the server; in this case the parameter is named "answerFromServer"
 +function onLoad() { 
 +                g_form.addInfoMessage("BEGIN Client Script"); 
 +  
 +                var ga = new GlideAjax('zJWJ_AjaxFunctions'); //phoenixAjaxUtils is the name of a Server Side Script Include CLASS. 
 +                ga.addParam("sysparm_name", "getMyTitle"); //One parameter must be named sysparm_name.  It tells which function to invoke on the server. 
 +                ga.getXMLAnswer(finishClientSideWork); //Call server function.  When it's complete, then invoke "finishClientSideWork" back here on the client. 
 +  
 +                g_form.addInfoMessage("Additional Code on Client Side 1"); 
 +  
 +                var ga2 = new GlideAjax('zJWJ_AjaxFunctions'); //phoenixAjaxUtils is the name of a Server Side Script Include CLASS. 
 +                ga2.addParam("sysparm_name", "getMyTitleWithPrefix"); //Tells which function to invoke on the server. 
 +                ga2.addParam("sysparm_Prefix", "Sir "); //Additional custom parameter. 
 +                ga2.getXMLAnswer(finishClientSideWorkTWO); //Call server function.  When complete, then invoke "finishClientSideWorkTWO" back here on the client. 
 +  
 +                g_form.addInfoMessage("Additional Code on Client Side 2"); 
 +
 +  
 +function finishClientSideWork(answerFomServer) 
 +
 +                g_form.addInfoMessage("BEGIN finishClientSideWorkONE"); 
 +                g_form.addInfoMessage("Title from Server: " + answerFomServer); 
 +                g_form.addInfoMessage("END finishClientSideWorkONE"); 
 +
 +  
 +function finishClientSideWorkTWO(answerFomServerTWO) 
 +
 +                g_form.addInfoMessage("BEGIN finishClientSideWorkTWO"); 
 +                g_form.addInfoMessage("Title from Server w Prefix: " + answerFomServerTWO); 
 +                g_form.addInfoMessage("END finishClientSideWorkTWO"); 
 +
 +</code> 
 +---- 
 + 
 +====c_GlideRecordDatabaseAccess==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====c_GlideRecordGetReferenceDatabaseAccess==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====c_ReusableScript==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====c_ScratchpadDatabaseAccess==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====c_TryBlock==== 
 +<code> 
 + 
 +</code> 
 + 
 +---- 
 +=====Server-Side Key Concepts===== 
 +====s_AjaxFunctionDefinition==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_CurrentAndPreviousGlideRecordObjects==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_EventDefinitionAndTriggering==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_ExcelFileProcessing==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_GeneratingMessages==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_GlideRecordDatabaseAccess==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_GlideRecordDatabaseInsert==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_JavaScriptArrays==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_JavaScriptObjects==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_LibraryClassAndFunctionUsage==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_LibraryClassDefinition==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_LibraryFunctionDefinition==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_MailScript==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_ScratchpadPopulation==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_SetRedirectURLFunction==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 +====s_TryBlock==== 
 +<code> 
 + 
 +</code> 
 +---- 
 + 
 + 
 + 
 + 
 +----
syntax_editor_macros.1736283630.txt.gz · Last modified: 01/07/2025 13:00 by johnsonjohn

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki