Postagens

Validating a data field in a Service Portal by using a Catalog Client Script

Imagem
      Use Case: When submitting a Record Producer, a date field can’t be in the past. How to accomplish this?       We can create a Catalog Client Script.       1) What is the trigger?       The script will run when the date field value changed.       2) What do we need to confirm?       We need to check if the date provided is in the future.       3) What if the date is not in the future?       If the date is not in the future, then we show an error message to inform that the date cannot be in the past.        Step by step process       1) Create a Record Producer (RP) and define the Catalog and Category so it will be visible in a Service Portal       2) Create a variable in y...

If you want to Update, please do not Insert!

Imagem
        There are scenarios when instead of updating a record, a script creates a new one. If it is the correct logic behind the Use Case it’s fine, but as good consultants we need to make sure it doesn’t happen if the client just want to perform updates.       1.1 Use Case 1: The get() method       In the script below we may think that the lines 9 to 11 are setting values to an existing record so in line 12 we’re just updating the record.       In the right panel we can see that, as the record wasn’t found, a new record was created in the sys_user table!       To guarantee that we are updating a record, it is important to wrap the get() method in an if statement like this:       If the record to be updated does not exist, the  else  statement is warning us about that fact and we’re not creating any unnecessary record. ...

How to get a parameter from the URL - Catalog Client Script

Imagem
      The mission was to get a sys_id from the URL, query a record and return a value to the front-end.       In the front-end we have a Record Producer (RP) with a String field.       On the onLoad event, we want to populate the field in order to show the value retrieved from the back-end.       The scenario is defined so let's go to the step by step process. 1. Create a Util class in the back-end       Our  Utils  class will be a Script Include that receives a sys_id and returns a String.   var KMXOUtils = Class.create(); KMXOUtils.prototype = { initialize: function() { }, /* * Receives a um sys_id and returns a Task table field value * * @param {String} - taskId * @return {Object} */ getTaskNumber: function(taskId) { if (taskId != "" && taskId != null && taskId != undefined) { var grTask = new Gl...

ServiceNow MVP

Imagem
  The ServiceNow MVP Community Program recognizes top individual contributors who are well known by the collective community for their product expertise, consistent quality contributions, and their esteemed character. ServiceNow MVPs demonstrate a commitment to engage, guide, and share their expertise with peers from around the globe. They are extraordinarily passionate about giving back to others and represent the voice of the greater community.

Teams notification

Imagem
We sent to a production instance a custom app where employees can inform webinars they attended, courses, ticket numbers that they solved recently, certifications, and so on. Each semester managers evaluate that information in order to pay bonuses. A manager with only one team can have five to twelve employees. And sometimes a manager can have two or more teams. When each employee sends the form, his/her manager needs to validate it so the system calculates a number of points. The problem: Managers don't want to access the platform every day to see if there are submissions to validate. It would be better to receive a smartphone notification when there were pending records. The solution: To send notifications to their smartphones we created a Flow using App Engine Studio. When a manager receives a notification, we make sure that there is an employee record to validate in the platform. What are the steps to accomplish this integration? In Microsoft Teams we are going to create a webh...