Skip to main content

Posts

Showing posts from July, 2021

Virtual Agent / Agent Workspace: create incident from chat / copy chat to worknotes

This is actually available to view from the incident within agent workspace https://docs.servicenow.com/bundle/paris-it-service-management/page/product/itsm-workspace/task/create-inci-from-chat-workflow.html in terms of copying chat to incident work notes, some ideas have been explored on the community: https://community.servicenow.com/community?id=community_question&sys_id=65008448dbc43c501cd8a345ca9619a9 [ and: https://community.servicenow.com/community?id=community_question&sys_id=19398fe1db5cdbc01dcaf3231f9619ec   https://community.servicenow.com/community?id=community_question&sys_id=bba79397dbd144985129a851ca9619f8    ]

Dynatrace APM (problem to incident): converting a DT date to SN format

  _formatDateforInc : function ( UTC_date ) { //--UTC format from Dynatrace: 02:39 (UTC) 28.07.2021 //--make it ServiceNow friendly var sReturn = "" ; try { var sUTC = UTC_date ; var sUTC_Arr = UTC_date . split ( "(UTC)" ); var sDtTr = sUTC_Arr [ 1 ]. trim (); var sDateOrderedArr = sDtTr . split ( "." ); var sDateOrdered = sDateOrderedArr [ 2 ]+ "-" + sDateOrderedArr [ 1 ]+ "-" + sDateOrderedArr [ 0 ]; //--2021-07-28 gs . print ( sDateOrderedArr [ 2 ]); var sDateFormatted = sDateOrdered + " " + sUTC_Arr [ 0 ]. trim () + ":00" ; var sGDTDate = new GlideDateTime ( sDateFormatted ); //--this appears to take care of UTC-GMT/BST out of the box /* var sBST = this._checkBST(sUTC_Arr[1].trim()); if (sBST=='BST'){ //--add an ...

ServiceNow REGEX grab the following string: between 2 words

ServiceNow REGEX grab the following string: between 2 words to get the value highlighted in yellow:  [code]<h3>OPEN Problem P-2107xxx in environment <i>Non Production</i></h3><br /><small> Problem detected at: 02:39 (UTC) 28.07.2021 </small><hr /><b>1 impacted application</b>< regex: var sDetails = grPrb . details + "" ; var testRE = sDetails . match ( " at: (.*) </small " ); gs . print ( testRE [ 1 ]); *** Script: 02:39 (UTC) 28.07.2021

Store constants in a script include

  you can then grab a const from within another script include like so: var sExistSource=Dynatrace_CONST . DYNATRACE_EXISTING_SOURCE

Format date to hh:mm (remove seconds)

Example usage: var grIncAlertTask = new GlideRecord('incident_alert_task'); if (grIncAlertTask.get('e84465641b026010f0dc85e4464bxxxx')) { var util = new mimDateUtil(grIncAlertTask.incident_alert.source_incident); util.setTimeFormat('hh:mm'); gs.print(util.formatDateField('sys_created_on')); } Script include: var mimDateUtil = Class . create (); mimDateUtil . prototype = { initialize : function ( gr , sDateFormat , sTimeFormat ) { this . gr = gr ; if (! sDateFormat ) this . setDateFormat (); if (! sTimeFormat ) this . setTimeFormat (); }, setDateFormat : function ( sDateFormat ) { this . sDateFormat = sDateFormat || 'dd-MM-yyyy' ; }, setTimeFormat : function ( sTimeFormat ) { this . sTimeFormat = sTimeFormat || 'hh:mm:ss' ; }, formatDateField : function ( sField ) { var sReturn...

Add an add/edit user UI Macro to a form

 based on ref: http://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/ (note this is a very old article so there may be better ways of doing this!) this adds a little + icon next to the caller field: notes : Show add/edit user macro icon on a reference field Activate by: – Setting the active field in this macro to true – Adding the attribute to a dictionary field: ref_contributions=_add_edit_user_modified sys property : the UI Macro : condition to hide/show the + icon <j:if test = "${(gs.getUser().getDepartmentID() == (gs.getProperty('hmcts.department')))&amp;&amp; gs.hasRole('itil_edit')}" > Full XML - view to set highlighted in green (view can be specified under system UI> views): <? xml version = "1.0" encoding = "utf-8" ?> <j:jelly trim = "false" xmlns:j = "jelly:core" xmlns:g = "glide" xmlns:j2 = "null" xmlns:g2 = "null...

Submit client script - submit the form

 look for the out of the box scripts with g_form.submit() for examples the following example involving a dialog window needs to ensure the mandatory worknotes do not interfere with form submission. Form submit script highlighted var _canSubmit = false ; var _dialog; function onSubmit () { if ( _canSubmit ) { return true ; } /* */ //Check for Assignment Group if ( g_form . getValue ( 'assignment_group' ) == g_scratchpad . hoth_assignmentGroup && g_scratchpad . serviceOfferingAntenna == true ) { var wNote = g_form . getValue ( 'work_notes' ); //If Work note updated if ( wNote != '' && wNote != null ) { g_form . setMandatory ( 'work_notes' , false ); //--don't block form submission g_form . clearMessages (); //Alert user to remove any Sensitive data /*-replace JS confirm wi...