Skip to content

Instantly share code, notes, and snippets.

@icerge
icerge / User preference changes.md
Last active July 21, 2022 08:41
Changing User preferences (language, timezone)

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.

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);

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);
@icerge
icerge / Sys ID values on insert of new record.md
Last active October 11, 2018 22:25
Are all these values equal on different stages? Is it always so? What about getUniqueValue()?
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;