Posts

Email Templates and Emails

 Email Templates and Emails Email Templates Links: To create a link, click on the link icon and in the URL add the link without the instance. e.g. /now/nav/ui/classic/params/target/pm_project.do%3Fsys_id=${sysapproval.sys_id} For approvals it will act on the table: Approval (sysapproval_approver) Use this type of syntax for getting variables when its to do with a Project: ${sysapproval} -> Gives the project number Approval Sys ID: ${sys_id} -> Gives the Approval Sysid ${sysapproval.sys_class_name} -> e.g. "Project" ${URI} -> Takes you to the approval record ${sysapproval.URI} -> Link to the project URL: sysapproval_approver.do?sys_id=${sys_id} Project sysid:  ${sysapproval.sys_id} Subject : ${sysapproval.short_description} Description : ${sysapproval.description} Click here to view Approval Request: ${URI} Click here to view ${sysapproval.sys_class_name}:  ${sysapproval.URI} Priority: ${sysapproval.priority} Category: ${sysapproval.category} Click...

Arrays

// Single Array - Push single values into an array.  // If there is a field which doenst have a single value but comma seperated values then split it and adds it to the arra y var x = 0; var st = ''; var ar = new Array(); var gr = new GlideRecord('cmdb_ci_service'); gr.addEncodedQuery("u_search_tagsISNOTEMPTY"); gr.query(); while (gr.next()) {   x++;   // gs.print(x + "  " + gr.u_search_tags);  // e.g.  Azure, Joe, Harry, OR Azure   st = gr.u_search_tags;   st = st.replace(/,\s*$/, ""); // Remove the last comma and any spaces if there are any   // Does it have a comma   if (st.indexOf(',') != -1) {     var sts = st.split(',');     for (var i = 0; i < sts.length; i++) {       //gs.print("----  " + x + "  --" + i + "  --" + sts.length + "  " + sts[i]); e..g        ar.push(sts[i]);       if (sts.length - 1 != i) {         x++; ...

Reference Qualifiers

Note 1: inverted commas are important Note 2: If you dont put javascript in front, it will change it from an Advanced to a Simple qualifier Note 3: Reference qualifiers are run on the Server side Example 1 javascript:'sys_class_name=service_offering^operational_status!=6^ORoperational_status=^parent='+current.business_service OR javascript:'parent='+current.business_service;

cat items

  To get actual values of the items use: current.cat_item.getDisplayValue() Otherwise use:  current.variables.u_rights.getDisplayValue()  // Set the Description of the REQ var req = new GlideRecord('sc_request'); if (req.get('sys_id', current.request)) {     req.description = "Assign rights to a Server "; //+current.cat_item.getDisplayValue()+'';     req.short_description = "Assign rights to a Server "; // +current.cat_item.getDisplayValue()+'';     req.update(); } // Set the Description of the RITM var ritm = new GlideRecord('sc_req_item'); if (ritm.get('sys_id', current.sys_id)) {     var desc = "Request for '" + current.variables.u_rights.getDisplayValue() + "' access rights for '" + current.variables.requested_for.getDisplayValue() + "'. \n";     if (current.variables.u_limitation == 'limit') {         desc = desc + "Limited access requested for " + cu...

Styles

 Client Script // Setting styles using client code function setStyle(response, control) { var style = response.responseXML.documentElement.getAttribute("answer"); control.setStyle(style); } function onChange(control, oldValue, newValue, isLoading, isTemplate) { //alert (oldValue + "  " + newValue); var tableName = g_form.getTableName(); // Change the background color based on status field. var ajax = new GlideAjax('ProjectStatusColorHelper'); ajax.addParam('sysparm_name', 'setStatusColor'); ajax.addParam('sysparm_value', newValue); ajax.addParam('sysparm_table_name', tableName); ajax.addParam('sysparm_field_name', 'u_status'); ajax.getXML(function(response) { setStyle(response, control); }); }

ACLs

Image
  For ACLs you first need access to the table, then to the field. Think of it as walking up to a house. You can't get in the house (table) without the door being unlocked. Once inside, the rooms, are the rows/fields. So those need to be unlocked as well to go in to those ( table.* or table.row/field ). For table.none means that you are applying the ACL at the table level. For table.*, means that you are applying this for all rows/fields on that table which don't have their own specific table.field ACL. So it's more of a "meta-ACL", if you will. Then there's table.row/field, means you are applying this for that specific field Example of a row level ACL (from chatGPT) Let's say you have an "Incident" table in ServiceNow, which contains records of various incidents reported by users. You want to restrict access to certain incidents based on their priority. You can define a row-level ACL that allows only users with a specific role, such as "Man...

Related Lists

 To change the name of a label of Related List: sys_translated_text.list Table Name= Relationship [sys_relationship] Document= e.g.  Relationship: Benefit Plans Change the Value Alternatively go to the List Control and make sure it has a "Label".  This label for example "Expense Lines" would then be translated in sys_translated.list To hide a related list, go to the form itself and hit the hamburger