0

Make a Better Notification with System Properties and Mail Scripts 0 (0)

The article below is intended for any person customize their Notifications. A working Javascript and HTML is useful but not required.

Introduction

We often focus on getting job done and ready to be delivered. Of course this is important but sometimes we need more than just doing it. In the following article, we will look how to automate and centralize data in one place in order to become scalable and easier to find and edit. 

Here’s a few things we will cover:

Use CaseExample
Automate properties (sys_properties)System properties store configuration information that rarely or never changes. Each time you change or add a system property, the system flushes the cache to keep all nodes in the cluster in synch. This cache flush has a very high performance cost for one to 10 minutes, which can potentially cause an outage if done excessively. To prevent such outages, do not use a system property to store configuration information that changes more than once or twice a month. I usually update the “From” field.
Use email templates (sysevent_email_template)Enable administrators to create reusable content for the subject line and message body of email notifications.Usually I define a mail_script (to use a standard style for all notifications), define subject and message.

 

Use Case Walkthrough

Use Case #1: Automate properties

  1. In the Navigation filter, enter sys_properties.list.The entire list of properties in the System Properties [sys_properties] table appears.
  2. Verify that the property does not exist by searching for the property name.
  3. Click New.
    Usually I use “company.default.notification.from”.
  4. Complete the System Property form.
    Type: String
    Value: Community Article <email@service-now.com>
  5. Navigate to System Definition > Business Rules.
  6. Click New.
  7. Fill in the fields, as appropriate.
    Tab When to run
    When: Before
    On Insert (check)
    On Update (check)
    Tab Advanced
    current.from = gs.getProperty(“company.default.notification.from”);
    gs.addInfoMessage(‘Loaded company.default.notification.from value’);

Use Case #2: Create a Template and assign to the Notification

  1. Navigate to System Policy > Email > Templates.
  2. Click New.

Fill in the form fields (see table).

In the “Message HTML”, usually I call a default stylesheet just in case of I need to change any HTML tag (font, size, etc).

  • Add <p>${mail_script:notification_email.styles}</p>.

To use a mail script, 

  • Navigate to System Notification > Email > Notifications Email Scripts. 
  • Click New: “Notification_email.styles”
  • On the your email script:
    var stylesheet = new GlideRecord (‘sp_css’);
    stylesheet.get(‘name’,’company_email_notifications.css’); //Stylesheet for email styling
    template.print(‘<div><style>’ + stylesheet.css + ‘</style></div>’);

3. Navigate to System Notification > Email > Notifications.
4. Open the email notification record that should use the template.
5. Navigate to the What it will contain section.
6. From the Email template field, select the appropriate template.
7. Click Update.

Conclusion

System properties are not limited to just Notifications, they’re part of the NOW Platform and can include anything we have in the Platform. Try to automate your instance and try to centralize all your “customer” data in one place.

Use all the tools at your disposal to make that happen.

1

Understanding User Types and Permissions on Customer Service Management (CSM) 0 (0)

The article below is intended for any person who is getting started with CSM or wants to do user management.

A working Javascript and HTML is useful but not required.

Leave a comment whenever you feel is missing any relevant information in this article.

Introduction

Since I started to use Customer Service module this always has been a struggle, quite hard to find a proper answer nowadays about best practises and how user management should be set up. Said that, my goal on this article is to provide you full picture how CSM was originally designed and how to get the most of it. I will update this article as often as I can with all information I collected so far.

According to ServiceNow documentation, Customer Service Management application enables you to route cases to available customer service agents with the necessary skill sets. Agents can make use of response templates and search tools to search the knowledge base and community and provide timely, informative responses to customers.

Customer information includes the account and contact information for a customer or partner.

  • An account is a supported external customer and the Account form stores the customer’s information, including the company name, contact names, addresses, phone numbers, and web and email addresses. An account can be a customer account, a partner account, or both.
  • contact is a user who is an employee of an account. A contact record stores information about a contact, such as the name, phone number, email and web address. An account can have multiple contacts but a contact can be associated with only one account. A contact can have one or more associated assets and service contracts. A contact can also have a user ID and can log in to the customer portal.

An account can have one or more associated assets, service contracts, entitlements, and SLAs. An account can also be associated with the following entities:

  • case
  • contact
  • service contract
  • entitlement
  • asset
  • partner is a supported external customer that, in turn, sells to and supports one or more customers. A partner account record stores information about a partner’s company, similar to a customer account. On a partner account record, the Partner field is enabled. A partner can report and manage cases on behalf of customers. A partner can also be a customer.

 Ok, that’s what is described on the official documentation but what’s really happening in the background?

image

Understanding user classes

When you mark a table as extendable, you are also adding a second system field: Class [sys_class_name] — System Class Name. It contains the name of the table that the record represents. The sys_id field uniquely identifies a record. In the case of an extended table, the sys_id field is actually stored in two places: on both the parent and child tables. The platform joins both together whenever you query the child table and the field sys_class_name is added on the parent table. 

In other words,  sys_class_name is to extend sys_user table to “User”, “Contact” or “Consumer”. 
When a User record is saved with class User , we get the details from SYS_USER table.
When a User record is saved with class ‘Contact’, we get details from extended SYS_USER and CUSTOMER_CONTACT table. The customer_contact table have some related lists such “Tickets”, Locations”, Social Profiles”.

Since my client is a B2B, for the moment I will not cover the consumer scenario on this article.  

As far I am aware, all admin should have a “User” class assigned and all customers and agents should have “Contact” assigned. 

The Customer Service Management application provides the ability to establish different types of relationships between partners, customers, and contacts. These relationships make account and asset management easy and flexible. The following types of customer service relationships are available. (link here). This will help to create a relationship such “regions” to your parent accounts providing a kind of hierachy parent-child to a specific account.

Permissions

Security is the mother of all mothers and nowadays that’s a buzz word. An administrator usually does this kind of questions:

  • If I want to someone to use my application, what roles they need?
  • If I want to someone support the cases, what roles they really need?

Customer Service Management includes both internal and external user roles. Internal user roles are for agents and agent managers using the Customer Service Management application. External user roles are for customers and partners using the customer portal.

Here’s roles you need to set up to your Agents or Customers:

Use CaseRoles
AgentAn agent is an employee of the company.Class: Usersnc_internalsn_customer_service_agentsn_esm_agent
CustomerA customer is a user who is an employee of an account.Class: Contact snc_externalsn_customerservice.customersn_esm_user
AdminClass: Useradmin

Note: Thank you @Kavita for helping me sorting this out. I was banging my head against the table over the reason of existence of this class. The official documentation provided lists all the roles available OOTB and how they should be used. Only customers should be contacts. 

The following table provides all roles available OOTB and how they are set up. 

Use CaseRoles
Create Casessn_customerservice.customersn_customerservice_agent
Delete Cases
 admin
Add assets/rooms/addresses/contracts/accounts manuallyOfficial documentation https://docs.servicenow.com/bundle/london-customer-service-management/page/product/customer-service-management/task/set-up-customer-information.htmlsn_customerservice_manageror admin
Run/create reports
Official documentation (https://docs.servicenow.com/bundle/london-performance-analytics-and-reporting/page/use/reporting/concept/c_AdminsteringReports.html). 
 itil
Modify users/groups lists etc
Official documentation https://docs.servicenow.com/bundle/london-platform-administration/page/administer/roles/reference/r_BaseSystemRoles.html
 user_admin
Schedule Customer service agents and field service techniciansOfficial documentation https://docs.servicenow.com/bundle/london-customer-service-management/page/product/customer-service-management/concept/agent-calendar_1.html agent_schedule_admin

Remember that all examples I provide is for a B2B scenario and for that reason the consumer roles is not included or mentioned. Therefore they’ve a very similar behaviour to the customers.

If you would like to go further on custom csm user roles, take a look on the documentation https://docs.servicenow.com/bundle/london-customer-service-management/page/product/customer-service-management/concept/creating-custom-csm-user-roles.html

Relationships

The Customer Service Management application provides the ability to establish different types of relationships between partners, customers, and contacts. These relationships make account and asset management easy and flexible. The following types of customer service relationships are available. (link here). This will help to create a relationship such “regions” to your parent accounts providing a kind of hierachy parent-child to a specific account.

Conclusions

There’s a gap in the documentation explaning how this module should properly work.
I will try to cover the maxium I can in order to be easier in the future to set up a Customer Service Mgt scenario.

0

Customise your UI Action Button or Navigation Bar of your forms 0 (0)

This onLoad client script shows how to change the background color of form buttons in ServiceNow. For this example, I set up the script to change the color of the ‘Approve and ‘Reject’ buttons on the approval form to green and red respectively. The script itself is pretty straight-forward and can be used as a model for targeting other DOM elements using client-side JavaScript.

function onLoad() {
   //Change the color of the 'Approve' button to green
   changeButtonColor('approve', '#00CC00');
   //Change the color of the 'Reject' button to red
   changeButtonColor('reject', '#CC0000');
}

function changeButtonColor(buttonID, backgroundColor) {
   try{
      //Find the button(s) by ID and change the background color
      $$('button[id=' + buttonID + ']').each(function(elmt) {
         elmt.style.backgroundColor = backgroundColor;
         elmt.style.color = '#ffffff'; //make the button text white
      });
   }catch(e){}
}

If you want to take this step a little bit further, you can add icons to UI actions.
Fortunately, with the addition of a new icon set in recent ServiceNow releases, this has become pretty simple to do.

image

The following script can be used in any standard form client script. The key is the ‘transformButton’ function at the bottom. This could be included as a global UI script in your instance so that you don’t need to include it in every single client script. Once that’s in place (whether in a global UI script or in the client script itself) you can just call ‘transformButton’ with the appropriate parameters to change the button however you want. The parameters used are as follows…

  1. UI action name (Mandatory)
  2. Button background color (Optional)
  3. Button text color (Optional)
  4. Button icon name (Optional)
function onLoad() {
    //Change the color of the 'Approve' button to green
    transformButton('approve', '#77FF77', 'white', 'icon-success-circle');
    //Change the color of the 'Reject' button to red
    transformButton('reject', '#FF0022', 'white', 'icon-error-circle');
    //Change the color of the 'Info' button to blue
    transformButton('info_button', '#31708f', 'white', 'icon-info');
    //Change the color of the 'Warning' button to yellow
    transformButton('warning_button', '#f0ad4e', 'white', 'icon-warning-circle');
}

function transformButton(buttonID, buttonBackgroundColor, buttonTextColor, buttonIconName) {
    try{
        //Find the button(s) by ID and change the background color
        $$('button[id=' + buttonID + ']').each(function(elmt) {
            elmt.style.backgroundColor = buttonBackgroundColor;
            if(buttonTextColor){
                elmt.style.color = buttonTextColor;
            }
            if(buttonIconName){
                elmt.addClassName(buttonIconName);
                //Add some spacing between the icon and button label
                elmt.innerHTML = ' ' + elmt.innerHTML;
            }
        });
    }catch(e){}
}

This same idea can be applied to form header colors as well by getting the HTML element of the form. You’re probably aware that ServiceNow provides a global CSS property to set the form and list header color. The global property can be found by navigating to System Properties -> CSS, and changing the ‘Banner and list caption background-color property.

function onLoad() {
   //Change the color of all form section headers
   var backgroundColor = 'red';
   $$('.navbar').each(function(elmt) {
      elmt.style.backgroundColor = backgroundColor;
   });
}
 (All credits go to ServiceNowGuru for this awesome finding!)

[Updated 30/09/2019]

As you may notice, the UI action element names differ (top from bottom) and for this, you need to add them also – you can verify the names by getting the HTML element of the form. (tested in Madrid)

function onLoad() {

changeButtonColor('approve', 'limegreen', 'white'); //approve button header
changeButtonColor('reject', 'red', 'white'); //reject button header
changeButtonColor('approve_bottom', 'limegreen', 'white'); //approve button bottom
changeButtonColor('reject_bottom', 'red', 'white'); //reject button bottom
}

function transformButton(buttonID, buttonBackgroundColor, buttonTextColor, buttonIconName) {
    try{
        //Find the button(s) by ID and change the background color
        $$('button[id=' + buttonID + ']').each(function(elmt) {
            elmt.style.backgroundColor = buttonBackgroundColor;
            if(buttonTextColor){
                elmt.style.color = buttonTextColor;
            }
            if(buttonIconName){
                elmt.addClassName(buttonIconName);
                //Add some spacing between the icon and button label
                elmt.innerHTML = ' ' + elmt.innerHTML;
            }
        });
    }catch(e){}
}

You can now change the colour by picking a form style.

I hope this helps.