0

Prevent Entities to get inactivate by mistake 0 (0)

Hi all,

I had few incidents in the past when entities get inactivated by mistake so I decided to leverage our entity management and improve UX to allow them (managers) to receive a popup message before they proceed with inactivation of an entity

Steps:

  1. Mark “Active” as read-only at dictionary level.
  2. Change your scope to “GRC: Profile”.
  3. Go to Profile [sn_grc_profile] and create a UI action called “Mark as inactive” with the following conditions:

    Name: Mark as inactive
    Action name: entity_retire
    Form button: true
    Show insert: true
    Show update: true
    Form style: destructive
    List style: destructive
    Client:  true

    Onclick: confirmAndRetireEntity()
    Condition: gs.getUser().hasRole(‘sn_grc.manager’) && current.active == true
    Script: 
    function confirmAndRetireEntity() { var gwt = new GwtMessage(); var title = gwt.getMessage('When a entity is retired, all related risks and controls are retired. Are you sure you want to continue?'); var modal = new GlideModal("sn_grc_retire_popup", false, 600, 450); modal.setTitle(gwt.getMessage('Confirmation')); modal.setPreference('sysparm_title', title); modal.setPreference('sysparm_sysid', g_form.getUniqueValue()); modal.setBackdropStatic(true); modal.setPreference('focusTrap', true); modal.setPreference('action_name', 'entity_retire'); modal.render(); return false; } if (typeof window == 'undefined') updateStatus(); function updateStatus() { current.setValue('active', 'false'); current.update(); action.setRedirectURL(current); }​

Result:
image

Note:

1. This pop up can be widely used (its generic) but it was originally created for Policies.

2. You need to create another button called “Mark as active” to perform the opposite behavior of this UI action. I gave “entity_enroll” as action name, change condition to run only on inactive records, change function name “confirmAndEnrollEntity()”, change line to “current.setValue(‘active’,’true’)” and thats it.

0

Introducing KICK – “When the supply meets the emergency demand” 0 (0)

(Whenever I remember that weekend, a tear of joy comes out. What a mix of emotions!)

Let me tell you our story.

Once upon a time a boy saw his life changed by an epidemic in March 2020. That epidemic stopped the world and the country as he knew it changed. Everyone wanted to fight the invisible enemy but the truth was that there wasn’t enough protection for everyone – the problem was something so close to all of us but for him, he saw his friends, family and acquaintances trying to make this world a little better – his mom is sewing scrubs for the NHS (in the video), friends and family have donated old bedsheets and going round collecting them. Then he started asking more questions and looking around, he saw that his old school were building visors and through that he ended up in touch with Carlton (in the video) which later he put him in touch with local councillor who sits on a team of local authority resiliency forum. Before go further, we would like to say a huge thank you to every single volunteer and organisation who has pulled together to solve the current supply chain issues being faced by frontline staff and key workers.

As the knowledge event approaches, ServiceNow surprised us and decided to make the world more digital. For the first time, we had the opportunity to participate in the ServiceNow event. Looking at Bill’s letter, and the response to COVID-19 with Emergency Response applications being made available and even demo instances for non-customers, we were overwhelmed with the opportunity – the CreatorCon Virtual Hackathon could not have happened at a more appropriate time. And.. the same boy who saw his life changed, was the same boy who made us all believe that KICK would be THE idea. We discussed, we planned, we delivered and this was the result. Hope you like it.

Introducing KICK – when supply meets emergency demand.

The platform to effectively manage demand and supply of key items during the crisis. KICK provides in time solutions for independent small businesses to provide click and collect services, available for voluntary groups to provide and manufacture goods and protective equipment. Key workers to source PPE. Requests can be made, stock can be transferred, logistics managed. Our solution easily serves the needs of local, regional and global groups looking to procure or source critical Personal Protective Equipment. We focused the tool on simplicity and usability using some of core platform features that have been bread and butter of ServiceNow.

Features embedded into our app include (but not limited to);
• Agent Workspace.
• Virtual Agent.
• NLU.
• Flow designer.
• Mobile app with barcode scanning.
• Service Portal to provide a simple interface for non-technical users.
• Service Catalog.
• Procurement for stock and transfer functionality.
• Knowledge Management.

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.

2

Function GlideTableDescriptor is not allowed in scoped applications 0 (0)

The code

GlideTableDescriptor.get(data.table).getED().hasAttribute("glide.security.ui.filter")

tests whether the table data.table has attribute with the name glide.security.ui.filter. No standart tables has the attribute. So you can just remove the part of code. If you do want to use the code, that you have to rewrite the fragment to get the same information about attributes of the table in alternative way.

I posted in my answer on the question the code of small function isTableAttributeEqualValue. The code shows how one can get attributes of table. You need just modify the last line of the code to use only return gr.next(). The resulting function will looks as following

function isTableHasAttribute (tableName, attributeName) {
	var gr = new GlideRecord("sys_schema_attribute_m2m");
	gr.addQuery("schema.name", tableName); // "Dictionary Entry"."Table"
	gr.addQuery("attribute.name", attributeName); // "Attribute"."Name"
	gr.query();
	return gr.next();
}

Then you can use isTableHasAttribute(data.table, “glide.security.ui.filter”) instead of GlideTableDescriptor.get(data.table).getED().hasAttribute(“glide.security.ui.filter”).

1

Heatmap lost their vivid colours on NY release 0 (0)

Apparently a new color definition (sys_report_color) “Risk Progress” has been introduced with New York release, changing the heatmap colors from using native UI14 Green/Red/Yellow to “Risk Progress Critical/High/Medium/Low/None”. They are no longer vivid, they look faded and washed out. This is confirmed by taking a look at NY release application files and searching for “sn_risk_color_setting” records.

According to Changes to New York features and products (https://docs.servicenow.com/bundle/newyork-release-notes/page/release-notes/summary/rn-summary-changes.html), it has been improved color contrast and modernized visualizations in the Performance Analytics and Reporting applications create a more consistent user experience.

Did you know about this? What do you think?

New York Release

image

Madrid or London release

image

To roll back to the previous colors system, please follow the next steps:

1. Go to Color Settings table (sn_risk_color_setting)

2. Update the color field according to the following table

image
0

Design a Powerful and Scalable Workflow with System Properties 0 (0)

The article below is intended for any person customise your Workflows. Javascript knowledge is useful but not required.

As I mentioned in other articles, regardless of your task, there aren’t always enough hours in the day to get everything done. As a result, you constantly feel like you’re always behind. And that’s just not good for your productivity or your health. Instead of putting in those extra hours, you can become more effective at work by focusing on what really matters. And you can get started with that ASAP by applying this quick scalable solution to your scripts. 



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 identify what can change in the future, like “group id”, “names”, etc.

Use Case Walkthrough

  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.workflow.default.L1″.
  4. Complete the System Property form.
    Type: String
    Value: <sys_user_group_id>
  5. Navigate to Workflow > Workflow Editor
  6. Edit your workflow and change script as appropriate.

Script
gs.getProperty(‘company.workflow.default.L1′);

Unfortunately there is no magic formula to identify which task or script or variable should be considered as system properties but to start you should think what can change over the time. 

Example #1:

Found some quite simple use case in the communities (link). A user would like to add a IF condition in the workflow to verify if the sys_property value is equal to true and then, the requester assigned will be XXX company and eventually will fire the next sc task. 

answer = ifScript();

function ifScript() {
    var prop = gs.getProperty('ab.provision.workflow');
    var comp = current.u_requestor.company.getDisplayValue(); //I am assuming u_requestor is the field company name

    if (prop == 'true' && comp == 'company name') {
        return 'yes';
    }
    return 'no';
}

Conclusion

System properties are not limited to just Notifications or Workflows, 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.

I will try to collect a use case for each type in order to help you to identify on which cases you should apply the sys property technique. 

0

Building a Dropdown in Jelly 0 (0)

If you want to create your dropdown list based on an array, please check the example below:

HTML

<!-- Values for select dropdown list-->

<g:evaluate>
var methods = [
{ name: 'Option number 1', value: 'Opt1' },
{ name: 'Option Number 2', value: 'Opt2' },
{ name: 'Option Number 3', value: 'Opt3' }
];
</g:evaluate>


<!-- Step #1 - Create dropdown for process type-->

<div class="form-group">
<label for="inputdefault" class="col-sm-2 control-label">Workflow Type:</label>
<div class="col-sm-10">
<!-- Step #1 - Start Select-->
<select class="form-control-static" id="dropdownId" name="dropdownId"   onchange="toggle_visibility(this); return false;">  
<option value="" selected="selected">-- Select --</option>  
<j:forEach items="${methods}" var="jvar_choice" indexVar="jvar_choice_id">
<g:evaluate jelly="true">
var name = jelly.jvar_choice.name;  
var value = jelly.jvar_choice.value;  
</g:evaluate>
</j:forEach>  
</select>  

<!-- Step #1 - End Select-->
  <div class="help-block">
  <j:if test="${!empty(jvar_choice)}">
  <label for="help_method_selected" id="help_method_selected"></label>
  </j:if>
  </div>      
</div>
</div>

Client script

getDrop = document.getElementById('dropdownId').value; process = trim(dropdownId);
console.log('var Demand Number: ' +getDrop);

Processing script

var p_dropdown = request.getParameter('dropdownId');
// For debugging
gs.info("MyDebug -INFO- Received form value for process ->" + p_dropdown);
gs.log("MyDebug -INFO- Received form, value for process ->" + p_dropdown);
0

The beginning of a new era: NOWJedi 0 (0)

Our step-by-step walkthrough of ServiceNow will take you from start to finish without ever getting you lost!

“Being a Jedi is not just about power, or lightsabres, or even skill with the Force. It is about connection. Being part of something bigger. I am stronger as part of the Jedi Order than I could ever be alone.”

— Obi-Wan Kenobi, to Anakin Skywalker 

Learning to be a ServiceNow Jedi is a commitment to simplicity and patience. You must train your mind and learn to live without emotional attachments. Enjoy what you have without excess. Neither Yoda nor Obi-Wan Kenobi lived lavishly, yet never complained. In the movies, the good guys adhered to the Light Side of the Force, emphasizing calmness, preserving life, and defending the weak.

A journey to becoming a Jedi is no simple task but ServiceNow made it simple.

The world works with ServiceNow and we work with them.