Sie sind auf Seite 1von 2

ServiceNow Syntax Macros Cheat Sheet

by kipp via cheatography.com/22363/cs/4566/


gslog

for

gs.log('['+gs.getUser().getFirstName()+'] VAR='+$0);

for (var i=0; i< myArray.length; i++) {

jslog

//myArray[i];

jslog("label: " +$0);

grq

info

var gr = new GlideRecord("$0");


gr.addQuery("name", "value");

gs.addInfoMessage("$0");

gr.query();
if (gr.next()) {

ajax


var ga = new GlideAjax('CLASS_NAME_HERE');
ga.addParam('sysparm_name', 'FUNCTION_NAME_HERE');
ga.addParam('sysparm_PARAMNAME', 'PARAMATER_VALUE');
ga.getXML(callBackParse);

}
GlideRecord Query with optional field parameter
grqor

function callBackParse(response) {

var gr = new GlideRecord('$0');

var answer =
response.responseXML.documentElement.getAttribute("ans

var qc = gr.addQuery('field', 'value1');

wer");

qc.addOrCondition('field', 'value2');

//insert processing code for answer here

gr.query();

$0

while (gr.next()) {

}
}

Inserts the client side ajax code

GlideRecord Query with optional field parameter and OR parameter


doc
//Short description goes here (one line)

stdrun
//Code to insert in a Run Script step.

/**
* DESCRIPTION: Supply a description of this script,

//The below sets the RITM short_description &


description values with sample fields from the Catalog

function, procedure, class etc.


* NOTES: None

Item variables.

* None

//You can copy from a catalog item form field or fill

* VERSIONS:

with your own description.

* 1.0 07/15/15 John Doe Original Version

//"stdtask" syntax editor macro could follow in a

* 1.1 07/15/15 John Doe Fixed screw-ups

CATTSK populating the short_description & description

***/

from the RITM values assigned here.


//REF: "stdtask" syntax editor macro.

Documentation header for scripts

//set the short_description & description on the RITM


current.short_description =
current.short_description+' '+current.variables.short_description;
current.description = current.variables.description;
'Run Script' code to initialize workflow variables

By kipp

Published 7th July, 2015.

Sponsored by Readability-Score.com

cheatography.com/kipp/

Last updated 24th July, 2015.

Measure your website readability!

Page 1 of 2.

https://readability-score.com

ServiceNow Syntax Macros Cheat Sheet


by kipp via cheatography.com/22363/cs/4566/
stdtask
//Code to insert in a CATTSK
//The below sets the CATTSK due_date, short_description &
description values.
//It copies the values from the RITM values which would work in
concert with the UI Macro "strrun"
//"stdrun" would previously have populated the RITM from the
Catalog Item variables.
//REF: "stdrun" syntax editor macro.
//set the task due date to the request item due date
task.due_date = current.due_date;
//set the short description to match the requested item
task.short_description = current.short_description;
//set the description to match the requested item description
task.description = current.description;
Script code to populate the CATTSK with RITM values
method
/*_________________________________________________________________
* Description:
* Parameters:
* Returns:
________________________________________________________________
*/
$0: function() {

},
JavaScript class method template
By kipp

Published 7th July, 2015.

Sponsored by Readability-Score.com

cheatography.com/kipp/

Last updated 24th July, 2015.

Measure your website readability!

Page 2 of 2.

https://readability-score.com

Das könnte Ihnen auch gefallen