{"id":16364,"date":"2022-10-12T06:55:00","date_gmt":"2022-10-12T04:55:00","guid":{"rendered":"https:\/\/sii.pl\/blog\/?p=16364"},"modified":"2023-05-10T15:54:42","modified_gmt":"2023-05-10T13:54:42","slug":"angular-bootstrap-calendar-in-service-portal","status":"publish","type":"post","link":"https:\/\/sii.pl\/blog\/en\/angular-bootstrap-calendar-in-service-portal\/","title":{"rendered":"Angular Bootstrap Calendar in Service Portal"},"content":{"rendered":"\n<p>In recent years ServiceNow has been established as the best tool to manage processes, services, or infrastructure. Named as the most innovative company by Forbes in 2018, ServiceNow operates in SaaS (software as a service) model constantly improving the platform.<\/p>\n\n\n\n<p>ServiceNow has many advantages and can be used in different fields. One of the advantages of the system is that it delivers a highly configurable and customizable component called <strong>Service Portal<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>By using this component we can extend or even create from the scratch user interface that will use other ServiceNow features. Service Portal is built using several well-known technologies.<\/p>\n\n\n\n<p>One of them is AngularJS, which is a popular front-end framework, that allows easily to create and maintain web applications with complex logic. The framework also allows using existing well-established solutions, which shortens significantly the time of developing certain customization.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Angular Bootstrap Calendar<\/strong><\/h2>\n\n\n\n<p>As an example, we can use the Angular Bootstrap Calendar widget which implements a very handful <strong>solution of calendar interface<\/strong>. To install this widget we need <a href=\"https:\/\/developer.servicenow.com\/connect.do#!\/share\/contents\/3031851_angular_bootstrap_calendar_widget?t=PRODUCT_DETAILS\" rel=\"nofollow\" >to download the update set<\/a> and then commit on our ServiceNow instance.<\/p>\n\n\n\n<p>After finishing this step successfully, we can find a page named angular_bootsrap_calendar in the Service Portal module.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sii.pl\/blog\/?attachment_id=16308\"><img decoding=\"async\" width=\"1024\" height=\"177\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-1-1-1024x177.png\" alt=\"Angular Bootstrap Calendar w Service Portalu\" class=\"wp-image-16308\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-1-1-1024x177.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-1-1-300x52.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-1-1-768x133.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-1-1.png 1040w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Fig. 1 Angular Bootstrap Calendar in Service Portal<\/figcaption><\/figure><\/div>\n\n\n\n<p>This is the entry point to the frontend logic, which we can customize later on according to our needs.<\/p>\n\n\n\n<p>We can use the page name to open it in the navigation bar, using a URL that looks like <em>https:\/\/instance_name.service-now.com\/sp?id=page_name<\/em>.<\/p>\n\n\n\n<p>In order to add or modify the logic we can either use the Service Portal page editor or we can open the Now UI Interface and from the container go to the widget.&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2.png\"><img decoding=\"async\" width=\"1024\" height=\"433\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2-1024x433.png\" alt=\"Page Content w Angular Bootstrap Calendar\" class=\"wp-image-16327\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2-1024x433.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2-300x127.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2-768x325.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-2-2.png 1324w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Fig. 2 Page Content in Angular Bootstrap Calendar<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Service Portal Widget<\/strong><\/h2>\n\n\n\n<p>In ServiceNow platform widget consists of four elements.<\/p>\n\n\n\n<p>HTML part which contains related static logic. As this part of platform uses AngularJS extensively, we can use here the framework directives.<\/p>\n\n\n\n<p>Then comes the CSS part responsible for the styling.<\/p>\n\n\n\n<p>When comes to scripting we have Client Script and Server Side.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Widget Scripts<\/strong><\/h3>\n\n\n\n<p>According to the names, <strong>in Client Script we place frontend logic, while the other contains backend operations<\/strong>. Client Script is essentially a controller which communicates with the server-side by the data object. It is pulled on page load, but we can also refresh it by using server.get method. Server Side part has access to all server API that is available for example Business Rules, and Script Includes. This is helpful especially for bringing data from the backend using GlideRecord API.<\/p>\n\n\n\n<p>The fact that both server and client-side, as well as the whole platform, is built on JavaScript, makes it easily maintainable and customizable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Bootstrap and AngularJS use case<\/strong><\/strong><\/h2>\n\n\n\n<p>The widget we describe in the article is called Test Angular Bootstrap Calendar, and as the name suggests for styling it uses the famous Bootstrap framework. We can use this tool in the whole ServicePortal, which is another enhancement of this ServiceNow application.<\/p>\n\n\n\n<p>When inspecting widget code we can notice that it contains another one, which is invoked by the sp-widget directive when the page is rendering.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2.png\"><img decoding=\"async\" width=\"1024\" height=\"379\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2-1024x379.png\" alt=\"Inspekcja kodu widgetu\" class=\"wp-image-16330\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2-1024x379.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2-300x111.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2-768x285.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-3-2.png 1317w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Fig. 3 Widget code inspection<\/figcaption><\/figure><\/div>\n\n\n\n<p>As you can see it\u2019s very simple to embed other widgets in your page which allows to create more powerful tools through the composition of other widgets. The second widget contains the configuration of the calendar navigation bar.<\/p>\n\n\n\n<p>When inspecting the server script of the main widget, we can see the code that is responsible for fetching data that later on will be rendered on the calendar page.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-4.png\"><img decoding=\"async\" width=\"970\" height=\"554\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-4.png\" alt=\"Struktura danych na przyk\u0142adzie tablicy Events\" class=\"wp-image-16314\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-4.png 970w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-4-300x171.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-4-768x439.png 768w\" sizes=\"(max-width: 970px) 100vw, 970px\" \/><\/a><figcaption>Fig. 4 Data structure on the example of the Events array<\/figcaption><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><strong>Data Object<\/strong><\/strong><\/h3>\n\n\n\n<p>As mentioned earlier GlideRecord is used for pulling data from backend. Thus, we can bring data from any table we want. It could be time_sheet table from Project Management Module application or custom table we have create for our custom purposes.<\/p>\n\n\n\n<p>However, in order to display data correctly we need to ensure it has proper structure. The example is supplied in the picture above under the array called events. Every element should have the properties like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>title,<\/li><li>color,<\/li><li>startsAt,<\/li><li>endsAt,<\/li><li>druggable,<\/li><li>resizable.<\/li><\/ul>\n\n\n\n<p>Some properties like recursOn are optional.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Logic customization and extension<\/strong><\/strong><\/h2>\n\n\n\n<p>While editing client script we can see following logic.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-5-1.png\"><img decoding=\"async\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-5-1.png\" alt=\"Logika podczas edytowania Client script\" class=\"wp-image-16318\" width=\"696\" height=\"392\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-5-1.png 696w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-5-1-300x169.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-5-1-555x312.png 555w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><figcaption>Fig. 5 Logic when editing Client script<\/figcaption><\/figure><\/div>\n\n\n\n<p>We can extend it or change it according our needs. The code above is responsible for invoking modal with details of certain event.<\/p>\n\n\n\n<p>We also have part that is responsible for formatting calendar text related to each event. However, we can extend this logic by adding our own filters that could show events for a certain user or given state.<\/p>\n\n\n\n<p>In order to achieve this, we have to supply proper properties in the event list mentioned before. We also need to define an additional function in the controller and invoke them on the HTML side using angular directives.<\/p>\n\n\n\n<p>Another way of extending and modifying the logic is using angular templates. In the widget, we can find them under the related list. In this example, it is file calendarControls.html, which contains the UI part responsible for choosing different options of the calendar view i.e. day, week, month.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1.png\"><img decoding=\"async\" width=\"1024\" height=\"315\" src=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1-1024x315.png\" alt=\"Wykorzystanie szablon\u00f3w Angulara do rozszerzania i modyfikowania logiki \" class=\"wp-image-16332\" srcset=\"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1-1024x315.png 1024w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1-300x92.png 300w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1-768x236.png 768w, https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/10\/Ryc.-6-1.png 1167w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Fig. 6 Using Angular templates to extend and modify logic<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Conclusion<\/strong><\/strong><\/h2>\n\n\n\n<p>The example described in our text shows how flexible and customizable is Service Portal. The fact that it uses such frameworks as AngularJS and Bootstrap makes it a very powerful and efficient tool for delivering a personalized solution.<\/p>\n\n\n\n<p>The fact that we can use plugins, tools, and libraries, shorten the time of delivering customer requirements. Which makes Service Portal a great tool for implementing ServiceNow features tailored to customer needs.<\/p>\n\n\n\n<p>***<\/p>\n\n\n\n<p>If you are interested in topics related to ServiceNow, we recommend other articles of our specialists, e.g. <a href=\"https:\/\/sii.pl\/blog\/en\/servicenow-integration-with-active-directory-using-ldap\/?category=soft-development&amp;tag=servicenow-2,active-directory-en,integration-en\">ServiceNow integration with Active Directory using LDAP<\/a>.<\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-left kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;16364&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;4&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;11&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;5\\\/5 ( votes: 4)&quot;,&quot;size&quot;:&quot;18&quot;,&quot;title&quot;:&quot;Angular Bootstrap Calendar in Service Portal&quot;,&quot;width&quot;:&quot;139.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} ( {votes}: {count})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 139.5px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 11px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 18px; height: 18px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 14.4px;\">\n            5\/5 ( votes: 4)    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>In recent years ServiceNow has been established as the best tool to manage processes, services, or infrastructure. Named as the &hellip; <a class=\"continued-btn\" href=\"https:\/\/sii.pl\/blog\/en\/angular-bootstrap-calendar-in-service-portal\/\">Continued<\/a><\/p>\n","protected":false},"author":462,"featured_media":19769,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_editorskit_title_hidden":false,"_editorskit_reading_time":4,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","inline_featured_image":false,"footnotes":""},"categories":[1320],"tags":[1644,1541,1542,1543],"class_list":["post-16364","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hard-development","tag-servicenow-en","tag-angular-bootstrap-calendar-2","tag-angularjs-2","tag-service-portal-2"],"acf":[],"aioseo_notices":[],"republish_history":[],"featured_media_url":"https:\/\/sii.pl\/blog\/wp-content\/uploads\/2022\/08\/Wykorzystanie-Angular-Bootstrap-Calendar-w-Service-Portalu.jpg","category_names":["Hard development"],"_links":{"self":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/16364"}],"collection":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/users\/462"}],"replies":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/comments?post=16364"}],"version-history":[{"count":3,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/16364\/revisions"}],"predecessor-version":[{"id":18924,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/posts\/16364\/revisions\/18924"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/media\/19769"}],"wp:attachment":[{"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/media?parent=16364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/categories?post=16364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sii.pl\/blog\/en\/wp-json\/wp\/v2\/tags?post=16364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}