var kb = new GlideRecord("kb_submission");
var sys_id_before_init = kb.sys_id;
// undefined
var sys_id_before_init = kb.getUniqueValue();
// null
kb.initialize();
var sys_id_after_initialize = kb.sys_id;
I come across this trick when a request is created from a call. Request is created and parent field is populated with call sys_id value.
var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;
action.setRedirectURL(url);
Evaluate your scripts safely, 'cause safity is #1 priority.
var name = "Processor";
// var int_custom = eval("new SIName" + name + "(xml, ticket);");
var gc = GlideController;
gc.putGlobal('xml', xml);
gc.putGlobal('ticket', ticket);
There is a business rule - Change Own Profile - sys_script.do?sys_id=e1d271450a0a0b440098a39d7d36903e It reflects the following user profile changes to user session:
- Language
- Timezone
- Time format
- Date format It runs if user changes own profile. The script uses API which isn't documented though. The interesting thing is that language session changes doesn't apply through session API calls.
Collection of methods to get URL to a record.
/*
Use GlideSubstituteURL class
.generateURL(GlideRecord, Record ID)
*/
var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());
There is a class GlideController. It's not documented. However you have definitly come across it. In client-callable script include, for example. Or in OOTB code :)
class
close
enforceSecurity
enforcingSecurity
equals
evaluate
evaluateAsObject
evaluateGeneratedString
Thread-Topic is a header of email message, it contains the original subject of the conversation
var headers = email.headers + "";
var topic_regex = /Thread-Topic:(.*)/i;
var topic_match = topic_regex.exec(headers);
var topic = (topic_match && topic_match[1]) ? topic_match[1] : email.subject;
well, there is a nice book, listing many Jelly features. Although, I don't know if it is mentioned there
Goal - validate form field values Alert message is get using 1 phase JAXL expression, JS: - prefix
function validateForm() {
if (gel('first_name').value == '') {
alert("${JS:gs.getMessage('Please input First Name')}");
return false;
I used to believe my operations are successful. Well, it's not a bullet proof.
var x = new GlideRecord('incident');
var sys_id = x.insert();
sys_id;
// GUID
x.isActionAborted()
Watch out performance of your queries!
var sw = new GlideStopWatch();
var recGR = new GlideRecord('cmdb_ci');
recGR.addQuery('sys_class_name', 'INSTANCEOF', 'cmdb_ci_server');
recGR.addQuery('name', 'ABCDEF');
recGR.setLimit(1);
recGR.query();
if (recGR.hasNext()) {