Search Results
16 results found with an empty search
- How to send email reminders in ServiceNow
Use Case If active incident is not updated in last 7 days then user in assigned to field should get reminder to update the ticket with latest status. Solution ServiceNow can send reminder emails by using scheduled jobs which can generate event once condition is matched as per the query of records. You can use gs.eventQueue() method for generating event in script. Method : gs.eventQueue(name,record,parm1,parm2,queue) Parameters : name - Name of the event to be generated. This event can be created in Event Registry. record - current record or glide record. Example - gr or current parm1 - Parameter to be used in scripting or sending email. Example - gr.assigned_to.email parm2 - Another Parameter. Example - gr.number queue- Provide queue name else leave empty for custom queue What elements need to be created Create a Scripted Schedule Create an Event in Event Registry Create a Notification Create a Scheduled Job for Script Execution Go to System Definitions > Scheduled Jobs Create New Scheduled Job Click on Automatically run a script of your choosing. Fill fields Name: send.reminder.email Run: Daily Time Zone : As per your requirement Script : var gr = new GlideRecord('incident'); gr.addEncodedQuery('active=true^sys_updated_on<javascript:gs.beginningOfLast7Days()'); gr.query(); while(gr.next()) { gs.eventQueue('inc.sendreminder',gr,gr.assigned_to.email,gr.number); } Create an event record in Event Registry Go to System Policy > Events > Registry Create new Event Name as inc.sendreminder Save the form Create Email Notification Go to System Notifications > Emails > Notifications Create New Notification Provide the name Select Incident table Select Send When as Event is Fired Event Name should be the event you have created in event registry. In this case it is inc.sendreminder You can provide other details like who will recieve and content of email Save the form You are Done! This way you can send reminders to different people if tickets are not getting updated.
- How to create custom popup alert box?
This will show you how can you create custom popup with designer buttons by using Glide Modal in ServiceNow. Use Case An alert popup always shows default browser alert which is added by adding alert() method in the client script. Customer is looking to for a custom popup which has colour and designer buttons. The use case is that when user changes the priority of the incident to Priority 1 on the form, then user should get alert which shows a message for P1. If user clicks OK, priority changes to Priority 1 on the client and if user clicks cancel then priority goes back to previous value. Step 1- Create a UI Page for custom alert. Name : saas_p1_alert (You can give name as per your choice) HTML: You've set priority of this ticket to P1. Ok Cancel Client Script: function processCancel(){ GlideDialogWindow.get().destroy(); //Close the dialog window g_form.setValue('impact',''); g_form.setValue('urgency',''); g_form.setValue('priority',''); } function okSubmit(){ GlideDialogWindow.get().destroy(); //Close the dialog window } Step 2 - Create a Client Script. Name: Show P1 Alert Table: Incident UI Type : All Type: On Change Field Name : Priority Script: function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } //Type appropriate comment here, and begin script below var priority = g_form.getValue('priority'); if (priority == '1'); { var gm = new GlideModal("saas_p1_alert"); //Sets the dialog title //gm.setTitle('Show title'); gm.setWidth(550); //Opens the dialog gm.render(); } } Learning We have used GlideModal in this solution which is calling the UI page. GlideModal is the replacement of GlideWindow which was introduced later. There is an important point here is that browser alert box is not testable with ATF however if you will use GlideModal then you can test with ATF. For More Info Click Here
- How to set a value on a field of the form or record in ServiceNow?
In this tutorial, you will learn how can you set a value on a field of a form on different conditions and scenarios. Setting the field value on load of the form Scenario: When incident form is loaded then the value of Caller field should populated with logged in user. Solution : This type of requirement can be achieved with Client Script as it needs to be set when form is loaded in the browser. Type of Script : Client Script Name : Populate Caller on the Incident Table : Incident UI Type : All Type : OnLoad Active : True Global: True Script : function onLoad() { //Type appropriate comment here, and begin script below if (g_form.isNewRecord()) { var currentUser = g_user.userID; g_form.setValue('caller_id', currentUser); } } Setting the field value on change of a field Scenario: When incident form is loaded then the Assignment Group should be populated with Network group. Solution : This type of requirement can be achieved with Client Script as it needs to be set when value oof Category field changes to Hardware. Type of Script : Client Script Name : Populate Caller on the Incident Table : Incident UI Type : All Type : OnChange Field: Category Active : True Global: True Script : function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } //Type appropriate comment here, and begin script below if (newValue == 'hardware') { //Setting SYSID OF Network Group g_form.setValue('assignment_group', '287ebd7da9fe198100f92cc8d1d2154e' ,'Network'); } }
- How to get Work Notes and Comments via ServiceNow API
If you will call ServiceNow Table API for Incident or any other Task table the you will not get worknotes and comments directly in the response and field will have empty data in response. In order to retrieve details of work notes and comments you have add a parameter which will automatically show all the work notes and comments in the response. Standard API EndPoint| Without Work notes and Comments in response If you will use standard ServiceNow API without any parameter then you will not get work notes in the response. API End Point : https://dev63008.service-now.com/api/now/table/incident/cb90e641db5c10101d94f26b68961961 Method : GET Response: { "result": { "parent": "", "made_sla": "true", "caused_by": "", "watch_list": "", "upon_reject": "cancel", "sys_updated_on": "2020-04-25 04:48:44", "child_incidents": "0", "hold_reason": "", "approval_history": "", "number": "INC0010215", "resolved_by": "", "sys_updated_by": "admin", "opened_by": { "link": "https://dev63008.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441", "value": "6816f79cc0a8016401c5a33be04be441" }, "user_input": "", "sys_created_on": "2020-04-19 07:41:09", "sys_domain": { "link": "https://dev63008.service-now.com/api/now/table/sys_user_group/global", "value": "global" }, "state": "1", "sys_created_by": "admin", "knowledge": "false", "order": "", "calendar_stc": "", "closed_at": "", "cmdb_ci": "", "delivery_plan": "", "impact": "3", "active": "true", "work_notes_list": "", "business_service": "", "priority": "5", "sys_domain_path": "/", "rfc": "", "time_worked": "", "expected_start": "", "opened_at": "2020-04-19 07:40:57", "business_duration": "", "group_list": "", "work_end": "", "caller_id": { "link": "https://dev63008.service-now.com/api/now/table/sys_user/62826bf03710200044e0bfc8bcbe5df1", "value": "62826bf03710200044e0bfc8bcbe5df1" }, "reopened_time": "", "resolved_at": "", "approval_set": "", "subcategory": "", "work_notes": "", "short_description": "TEST 3", "close_code": "", "correlation_display": "Acer", "delivery_task": "", "work_start": "", "x_26123_snow_ebond_bonded": "false", "assignment_group": { "link": "https://dev63008.service-now.com/api/now/table/sys_user_group/0a52d3dcd7011200f2d224837e6103f2", "value": "0a52d3dcd7011200f2d224837e6103f2" }, "x_26123_snow_ebond_vendor_ticket": "INC0010231", "additional_assignee_list": "", "business_stc": "", "description": "", "calendar_duration": "", "close_notes": "", "notify": "1", "sys_class_name": "incident", "closed_by": "", "follow_up": "", "parent_incident": "", "sys_id": "cb90e641db5c10101d94f26b68961961", "contact_type": "", "reopened_by": "", "incident_state": "1", "urgency": "3", "problem_id": "", "company": { "link": "https://dev63008.service-now.com/api/now/table/core_company/227cdfb03710200044e0bfc8bcbe5d6b", "value": "227cdfb03710200044e0bfc8bcbe5d6b" }, "reassignment_count": "0", "activity_due": "", "assigned_to": "", "severity": "3", "comments": "", "approval": "not requested", "sla_due": "", "comments_and_work_notes": "", "due_date": "", "sys_mod_count": "2", "reopen_count": "0", "sys_tags": "", "escalation": "0", "upon_approval": "proceed", "correlation_id": "3eb23c03db1010101d94f26b689619f4", "location": "", "category": "inquiry" } } Updated API EndPoint With Worknotes and Comments in response In order to get work notes in the response you have to add a parameter in URL of API sysparm_display=true. API End Point : https://dev63008.service-now.com/api/now/table/incident/cb90e641db5c10101d94f26b68961961?sysparm_display_value=true Method : GET Response: { "result": { "parent": "", "made_sla": "true", "caused_by": "", "watch_list": "", "upon_reject": "cancel", "sys_updated_on": "2020-04-25 04:48:44", "child_incidents": "0", "hold_reason": "", "approval_history": "", "number": "INC0010215", "resolved_by": "", "sys_updated_by": "admin", "opened_by": { "link": "https://dev63008.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441", "value": "6816f79cc0a8016401c5a33be04be441" }, "user_input": "", "sys_created_on": "2020-04-19 07:41:09", "sys_domain": { "link": "https://dev63008.service-now.com/api/now/table/sys_user_group/global", "value": "global" }, "state": "1", "sys_created_by": "admin", "knowledge": "false", "order": "", "calendar_stc": "", "closed_at": "", "cmdb_ci": "", "delivery_plan": "", "impact": "3", "active": "true", "work_notes_list": "", "business_service": "", "priority": "5", "sys_domain_path": "/", "rfc": "", "time_worked": "", "expected_start": "", "opened_at": "2020-04-19 07:40:57", "business_duration": "", "group_list": "", "work_end": "", "caller_id": { "link": "https://dev63008.service-now.com/api/now/table/sys_user/62826bf03710200044e0bfc8bcbe5df1", "value": "62826bf03710200044e0bfc8bcbe5df1" }, "reopened_time": "", "resolved_at": "", "approval_set": "", "subcategory": "", "work_notes": "2020-04-24 21:48:36 - System Administrator (Work notes)\nTest for Worknotes\n\n2020-04-19 00:41:09 - System Administrator (Work notes)\nsdsdsdd\n\n", "short_description": "TEST 3", "close_code": "", "correlation_display": "Acer", "delivery_task": "", "work_start": "", "x_26123_snow_ebond_bonded": "false", "assignment_group": { "link": "https://dev63008.service-now.com/api/now/table/sys_user_group/0a52d3dcd7011200f2d224837e6103f2", "value": "0a52d3dcd7011200f2d224837e6103f2" }, "x_26123_snow_ebond_vendor_ticket": "INC0010231", "additional_assignee_list": "", "business_stc": "", "description": "", "calendar_duration": "", "close_notes": "", "notify": "1", "sys_class_name": "incident", "closed_by": "", "follow_up": "", "parent_incident": "", "sys_id": "cb90e641db5c10101d94f26b68961961", "contact_type": "", "reopened_by": "", "incident_state": "1", "urgency": "3", "problem_id": "", "company": { "link": "https://dev63008.service-now.com/api/now/table/core_company/227cdfb03710200044e0bfc8bcbe5d6b", "value": "227cdfb03710200044e0bfc8bcbe5d6b" }, "reassignment_count": "0", "activity_due": "", "assigned_to": "", "severity": "3", "comments": "", "approval": "not requested", "sla_due": "", "comments_and_work_notes": "", "due_date": "", "sys_mod_count": "2", "reopen_count": "0", "sys_tags": "", "escalation": "0", "upon_approval": "proceed", "correlation_id": "3eb23c03db1010101d94f26b689619f4", "location": "", "category": "inquiry" } }
.png)





