Skip to main content

Posts

Showing posts from November, 2020

ServiceNow Scriptable service catalog variables - update a variable

ServiceNow Scriptable service catalog variables - update a variable  https://docs.servicenow.com/bundle/paris-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html e.g. back-fill a missing variable var gr = new GlideRecord ( 'sc_req_item' ); gr . addActiveQuery (); gr . addQuery ( 'cat_item' , '8e6430cadbaf9c1011eaa0214b96xxxx' ); //--general request gr . query (); var bUpdate = false ; //bUpdate=true; var iCount = 0 ; while ( gr . next ()) { if ( gr . variables . request_type == '' ) { gs . print ( gr . number ); iCount ++; if ( bUpdate ) { gr . variables . request_type = '38' ; gr . update (); //break; } /*var set = new GlideappVariablePoolQuestionSet(); set.setRequestID(gr.sys_id); set.load(); var vs = set.getFlatQuestions(); for (var i = 0; i < vs.s

Copy attachments from email when using cart object in inbound action, set target record

 see  https://community.servicenow.com/community?id=community_question&sys_id=d9c73a60db483f8413b5fb24399619bd it seems that you need to get the sys_id of the REQ table GlideSysAttachment . copy ( 'sys_email' ,  sys_email . sys_id ,   'sc_request' ,   rc.sys_id ) ; https://community.servicenow.com/community?id=community_question&sys_id=927007e1db98dbc01dcaf3231f961970 set target to the REQ table sys_email.target_table = "sc_request"; sys_email.instance = rc.sys_id; or RITM table if(rc != undefined){ var gr = new GlideRecord("sc_req_item"); gr.addQuery("request", rc.sys_id); gr.query(); if(gr.next()){ sys_email.target_table = "sc_req_item"; sys_email.instance = gr.sys_id; sys_email.update(); } }

known issue with inherited role removal

 below script can be used as a workaround to tidy up inherited roles which can't be removed which is being caused by the inherited flag being set to true on sys_user_has_role var grUser = new GlideRecord ( 'sys_user' ); if ( grUser . get ( 'sys_id' , '539be781dbfc5010dde5d8c2f39xxxxx' )){ gs . print ( grUser . name ); var grGrpMem = new GlideRecord ( 'sys_user_has_role' ); grGrpMem . addQuery ( 'user' , grUser . sys_id ); grGrpMem . addQuery ( 'inherited' , true ); grGrpMem . query (); gs . print ( grGrpMem . getRowCount ()); while ( grGrpMem . next ()){ //grGrpMem.autoSysFields(false);//--leave last updated intact //grGrpMem.setWorkflow(false); grGrpMem . inherited = false ; grGrpMem . update (); gs . print ( grGrpMem . sys_id ); grGrpMem . deleteRecord (); } }

Accessing the login page

 this is actually located under system UI> welcome page content https://docs.servicenow.com/bundle/istanbul-platform-user-interface/page/administer/navigation-and-ui/concept/c_WelcomePageContent.html?title=Welcome_Page_Content#gsc.tab=0 

Setting stages in request item workflows

 go to the workflow properties> stages tab 

Group tasks widget in Service Portal

  widget takes you back into classic UI view when the task number is clicked. Lists all ticket types assigned to the group the logged in user belongs to script - HTML <div class = "panel panel-default" > <div class = "panel-heading clearfix" > <div class = "pull-right" > <a class = "btn btn-default btn-sm" ng-click = "showFilters = !showFilters" ><i class = "fa fa-filter" ></i></a> </div> <div class = "panel-title" > My Groups Tasks </div> </div> <div class = "panel-body" ng-show = "showFilters" > <form class = "form-inline" > <div class = "form-group" > <label for = "textSearch" > Search </label> <input id = "textSearch" class = "form-control" type = "text"