From 8646e97e98c872af23ddb8c6f696befc6cef4f8d Mon Sep 17 00:00:00 2001 From: snamjosh <38986112+snamjosh@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:19:08 -0700 Subject: [PATCH 1/3] Create readme.js --- Service Portal/spOnReady/readme.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Service Portal/spOnReady/readme.js diff --git a/Service Portal/spOnReady/readme.js b/Service Portal/spOnReady/readme.js new file mode 100644 index 0000000..110015f --- /dev/null +++ b/Service Portal/spOnReady/readme.js @@ -0,0 +1,3 @@ +This syntax macro Get data from the background and make it accessible after it is retrieved. + +e.g This macro can be used during server script during service portal widget development. From 15e5b0654232606a89bbbdc0d1bfe4b3d149be6d Mon Sep 17 00:00:00 2001 From: snamjosh <38986112+snamjosh@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:20:11 -0700 Subject: [PATCH 2/3] Create sp_onready.js --- Service Portal/spOnReady/sp_onready.js | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Service Portal/spOnReady/sp_onready.js diff --git a/Service Portal/spOnReady/sp_onready.js b/Service Portal/spOnReady/sp_onready.js new file mode 100644 index 0000000..a690fa4 --- /dev/null +++ b/Service Portal/spOnReady/sp_onready.js @@ -0,0 +1,27 @@ +//add keyup event listener + jQuery(window).on('keyup', fn); + + //populate macrosObj with records from the Syntax Editor Macro table + var requestBody = ""; + var client=new XMLHttpRequest(); + client.open("get","/api/now/table/syntax_editor_macro?sysparm_fields=name%2Ctext"); + + client.setRequestHeader('Accept','application/json'); + client.setRequestHeader('Content-Type','application/json'); + client.setRequestHeader('X-UserToken',window.g_ck); + + var rsc = function(){ + if(this.readyState == this.DONE) { + var rspObj=JSON.parse(this.response).result; + for(var macro in rspObj){ + if(!rspObj.hasOwnProperty(macro)) + continue; + + var currentMacro=rspObj[macro]; + macrosObj[currentMacro.name]=currentMacro; + } + } + }; + + client.onreadystatechange = rsc; + client.send(requestBody); From 3011cb2f85f90040db3fa2803fa009681f3dde91 Mon Sep 17 00:00:00 2001 From: snamjosh <38986112+snamjosh@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:10:49 -0700 Subject: [PATCH 3/3] Updated readme.md to modify description. Updated readme file description based on reviewer comments. --- Service Portal/spOnReady/{readme.js => readme.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Service Portal/spOnReady/{readme.js => readme.md} (51%) diff --git a/Service Portal/spOnReady/readme.js b/Service Portal/spOnReady/readme.md similarity index 51% rename from Service Portal/spOnReady/readme.js rename to Service Portal/spOnReady/readme.md index 110015f..c72d290 100644 --- a/Service Portal/spOnReady/readme.js +++ b/Service Portal/spOnReady/readme.md @@ -1,3 +1,3 @@ This syntax macro Get data from the background and make it accessible after it is retrieved. -e.g This macro can be used during server script during service portal widget development. +e.g This macro can be used from client script during service portal widget development.