Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Service Portal/spOnReady/readme.md
Original file line number Diff line number Diff line change
@@ -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 from client script during service portal widget development.
27 changes: 27 additions & 0 deletions Service Portal/spOnReady/sp_onready.js
Original file line number Diff line number Diff line change
@@ -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);
Loading