\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Bibin Gokuldas (bibingokuldas)} \pdfinfo{ /Title (serviceportal-cheat-sheet.pdf) /Creator (Cheatography) /Author (Bibin Gokuldas (bibingokuldas)) /Subject (ServicePortal Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{130F4F} \definecolor{LightBackground}{HTML}{F7F7F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{ServicePortal Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Bibin Gokuldas (bibingokuldas)} via \textcolor{DarkBackground}{\uline{cheatography.com/69673/cs/23975/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Bibin Gokuldas (bibingokuldas) \\ \uline{cheatography.com/bibingokuldas} \\ \uline{\seqsplit{bibingokuldas}.com/} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 26th September, 2020.\\ Updated 26th September, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{CSS Sequence (Execution Order)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-angle-double-right\}\}ServiceNow Specific StyleSheet \newline % Row Count 2 (+ 2) \{\{fa-angle-right\}\}Generated Bootstrap CSS \newline % Row Count 3 (+ 1) \{\{fa-asterisk\}\}Including Portal and Theme records' CSS at the top of this blob \newline % Row Count 5 (+ 2) \{\{fa-angle-double-right\}\}Patch \newline % Row Count 6 (+ 1) \{\{fa-angle-double-right\}\}Each CSS Include's Style Sheet record's CSS \newline % Row Count 8 (+ 2) \{\{fa-asterisk\}\}Including Portal and Theme records' CSS at the top of each blob \newline % Row Count 10 (+ 2) \{\{fa-angle-double-right\}\}Font-Awesome \newline % Row Count 11 (+ 1) \{\{fa-angle-double-right\}\}Page record's CSS \newline % Row Count 12 (+ 1) \{\{fa-asterisk\}\}Including Portal and Theme records' CSS at the top of this blob \newline % Row Count 14 (+ 2) \{\{fa-angle-double-right\}\}Alternating Sequence of: \newline % Row Count 15 (+ 1) \{\{fa-angle-double-right\}\}Each Widget record's CSS \newline % Row Count 17 (+ 2) \{\{fa-asterisk\}\}Including Portal and Theme record CSS at the top of each blob \newline % Row Count 19 (+ 2) \{\{fa-angle-double-right\}\}Each Widget's Instance records' Stylesheets \newline % Row Count 21 (+ 2) \{\{fa-asterisk\}\}Including Portal and Theme record CSS at the top of each blob% Row Count 23 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Angular Directives}} \tn % Row 0 \SetRowColor{LightBackground} Evaluate the given expression when the user changes the input. & \seqsplit{`ng-change="expression"`} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Sets the checked attribute on the element & \seqsplit{`ng-checked="boolean"`} \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} This directive sets the disabled attribute on the element & \seqsplit{`ng-disabled="boolean"`} \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} The ngHide directive shows or hides the given HTML element based on the expression provided to the ngHide attribute. & \seqsplit{`ng-hide|show="boolean"`} \tn % Row Count 16 (+ 6) % Row 4 \SetRowColor{LightBackground} The ngMousedown directive allows you to specify custom behavior on mousedown event. & \seqsplit{`ng-mousedown="expression"`} \tn % Row Count 21 (+ 5) % Row 5 \SetRowColor{white} Specify custom behavior on mouseover event & \seqsplit{`ng-mouseover="expression"`} \tn % Row Count 24 (+ 3) % Row 6 \SetRowColor{LightBackground} Specify custom behavior on blur event. A blur event fires when an element has lost focus. & \seqsplit{`ng-blur="expression"`} \tn % Row Count 29 (+ 5) % Row 7 \SetRowColor{white} Run a loop with the data in array & `ng-repeat="({[}key,{]} value) in object|array"` \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Angular Directives (cont)}} \tn % Row 8 \SetRowColor{LightBackground} Evaluate an if condition & \seqsplit{`ng-if="expression"`} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.2 cm} x{4.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Client script global functions}} \tn % Row 0 \SetRowColor{LightBackground} `this.server.get({[}Object{]})` & Calls the server and sends custom input. Returns Promise. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{`this.server.update()`} & Calls the server and posts this.data to the server script. Returns Promise. \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} \seqsplit{`this.server.refresh()`} & Calls the server and automatically replaces the current options and data from the server response. Returns Promise. \tn % Row Count 12 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{A promise represents the eventual result of an asynchronous operation. For more information on promises, see \seqsplit{https://promisesaplus.com/} or AngularJS documentation.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{spAriaUtil - Client}} \tn % Row 0 \SetRowColor{LightBackground} Announce a message to a screen reader. & ` \seqsplit{spAriaUtil.sendLiveMessage('Say} Hello to screen reader');` \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{The spAriaUtil service is an angular service included as part of the Service Portal angular application. The spAriaUtil service is available in the client script block of Service Portal widgets.}} \newline {\bf{{\emph{To use the spAriaUtil please add the same to client controller}}}} \newline `function(spAriaUtil) \{` \newline `/{\emph{ widget controller }}/` \newline `var c =this;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{spUtil - Client}} \tn % Row 0 \SetRowColor{LightBackground} Displays a notification error message. & \seqsplit{`spUtil.addErrorMessage("There} has been an error processing your request")` \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Displays a notification info message. & \seqsplit{`spUtil.addInfoMessage("Your} order has been placed")` \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} Displays a trivial notification message.\{\{nl\}\}{\emph{Trivial messages disappear after a short period of time.}} & \seqsplit{`spUtil.addTrivialMessage("Thanks} for your order")` \tn % Row Count 13 (+ 6) % Row 3 \SetRowColor{white} Use this method to embed a widget model in a widget client script. The callback function returns the full widget model. & \seqsplit{`spUtil.get('pps-list-modal'}, \{title: \seqsplit{c.data.editAllocations},`\{\{nl\}\} `table: \seqsplit{'resource\_allocation'},`\{\{nl\}\} `queryString: 'GROUPBYuser\textasciicircum{}resource\_plan=' + c.data.sysId,`\{\{nl\}\} `view: \seqsplit{'resource\_portal\_allocations'} \}).then(function(response) \{`\{\{nl\}\} `var formModal = response;`\{\{nl\}\} \seqsplit{`c.allocationListModal} = response;`\{\{nl\}\} `\});` \tn % Row Count 31 (+ 18) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{spUtil - Client (cont)}} \tn % Row 4 \SetRowColor{LightBackground} Formats a string as an alternative to string concatenation.\{\{nl\}\}{\emph{Use this method to build a string with variables.}} & `spUtil.format('An error ocurred: \{error\} when loading \{widget\}', \{error: '404', widget: 'sp-widget'\})` \tn % Row Count 6 (+ 6) % Row 5 \SetRowColor{white} Calls the server and replaces the current options and data with the server response. & \seqsplit{`spUtil.refresh(\$scope)`} \tn % Row Count 11 (+ 5) % Row 6 \SetRowColor{LightBackground} Updates the data object on the server within a given scope. & \seqsplit{`spUtil.update(\$scope)`} \tn % Row Count 14 (+ 3) % Row 7 \SetRowColor{white} Watches for updates to a table or filter and returns the value from the callback function. & \seqsplit{`spUtil.recordWatch(\$scope}, "problem", "active=true", function(response) \{`\{\{nl\}\} `// Returns the data inserted or updated on the table`\{\{nl\}\} \seqsplit{`console.log(response}.data);`\{\{nl\}\} `\});` \tn % Row Count 24 (+ 10) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{Utility methods to perform common functions in a Service Portal widget client script.}} \newline {\bf{{\emph{To use the spUtil functions in the client controller, ensure that you add to client function}}}} \newline `function(spUtil,\$scope) \{` \newline `/{\emph{ widget controller }}/` \newline `var c =this;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Internationalize a widget}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-asterisk\}\}Use the \$\{\} or gs.getMessage() syntax in widgets to tag strings for translation so you can localize your Service Portal content. \newline % Row Count 3 (+ 3) `\textless{}div\textgreater{}` \newline % Row Count 4 (+ 1) `\textless{}p\textgreater{}\$\{This message will be translated.\}\textless{}/p\textgreater{}` \newline % Row Count 5 (+ 1) `\textless{}p\textgreater{}However, this will nessage will NOT be translated.\textless{}/p\textgreater{}` \newline % Row Count 7 (+ 2) `\textless{}/div\textgreater{}` \newline % Row Count 8 (+ 1) Now to translate the above, add the text in sys\_ui\_message to get the respective translation \newline % Row Count 10 (+ 2) ex: \newline % Row Count 11 (+ 1) \{\{fa-angle-right\}\}Key: This message will be translated. \newline % Row Count 13 (+ 2) \{\{fa-angle-right\}\}Language : 'de' / 'fr' / 'it' \newline % Row Count 14 (+ 1) \{\{fa-angle-right\}\}Message : Add the translated text% Row Count 16 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{GlideSPScriptable - Scoped}} \tn % Row 0 \SetRowColor{LightBackground} `if the user can read the specified GlideRecord.` & `\$sp.canReadRecord(\textless{}gliderecord\textgreater{})` \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} `if the user can read the specified record with table and sysID` & \seqsplit{`\$sp.canReadRecord('table'}, 'sys\_id')` \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} `if the currently logged in user has permission to view the specified page` & \seqsplit{`GlideSPScriptable.canSeePage("page\_id")`} \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} `Returns a model and view model for a sc\_cat\_item or \seqsplit{sc\_cat\_item\_guide}.` & \seqsplit{`\$sp.getCatalogItem(sys\_id)`} \tn % Row Count 15 (+ 4) % Row 4 \SetRowColor{LightBackground} `Returns the display value of the specified field (if it exists and has a value) from either the widget's sp\_instance or the sp\_portal record.` & \seqsplit{`\$sp.getDisplayValue("sc\_catalog")`} \tn % Row Count 23 (+ 8) % Row 5 \SetRowColor{white} `Returns the portal record from the Service Portals {[}sp\_portal{]} table.` & \seqsplit{`\$sp.getPortalRecord()`} \tn % Row Count 27 (+ 4) % Row 6 \SetRowColor{LightBackground} `Returns an array of Service Catalog variables associated with a record.` & \seqsplit{`\$sp.getRecordVariablesArray('sc\_req\_itemGlide} record',true(if you want variables with no values));` \tn % Row Count 32 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{GlideSPScriptable - Scoped (cont)}} \tn % Row 7 \SetRowColor{LightBackground} `Gets a widget by id or sys\_id, executes that widget's server script using the provided options, then returns the widget model.` & \seqsplit{`\$sp.getWidget('widget\_id'}, \{p1: param1, p2: param2\});` \tn % Row Count 7 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{`{\emph{Interact with data and perform record operations in Service Portal widgets.}}` \newline `{\emph{You access GlideSPScriptable methods by using the global \$sp object.}}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{CSS Hierarchy}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/bibingokuldas_1598249083_CSS Hierarchy.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Global objects in widgets}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-angle-double-right\}\} {\bf{Server Side Objects}} \newline % Row Count 1 (+ 1) \{\{fa-angle-right\}\}{\bf{{\emph{input}}}} :{\emph{Sent from Client script}} \newline % Row Count 3 (+ 2) \{\{fa-angle-right\}\}{\bf{{\emph{options}}}} :{\emph{Configurations mentioned in widget options when widget is loaded}} \newline % Row Count 5 (+ 2) \{\{fa-angle-right\}\}{\bf{{\emph{data}}}} :{\emph{Object or properties/value pair sent to client}} \newline % Row Count 7 (+ 2) \{\{nl\}\} \newline % Row Count 8 (+ 1) \{\{fa-angle-double-right\}\} {\bf{Client Side Objects}} \newline % Row Count 9 (+ 1) \{\{fa-angle-right\}\}{\bf{{\emph{options}}}} :{\emph{Configurations mentioned in widget options when widget is loaded}} \newline % Row Count 11 (+ 2) \{\{fa-angle-right\}\}{\bf{{\emph{data}}}} :{\emph{ Serialized data object from Server script}}% Row Count 13 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{The "snRecordPicker"}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-asterisk\}\} Creating a reference Field \newline \textless{}sn-record-picker field="" \newline table="'sys\_user'" \newline display-field="'name'" \newline \seqsplit{display-fields="'user\_name'"} \newline value-field="'sys\_id'" \newline search-fields="'name'" \newline \seqsplit{default-query="'nameLIKEAdmin'"} \newline page-size="100" \textgreater{}\textless{}/sn-record-picker\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\emph{When you try and include a reference field (such as "department") in the "display-fields" parameter, the field that you specify doesn't render other non reference fields do render correctly. This is an existing issue can be found in the KB0717097 }} \newline {\emph{you can pass in the filter you need to apply on reference field using default-query attribute}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{The "sp-date-picker"}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-asterisk\}\} The sp-date-picker allows to select a date and time in widgets \newline \textless{}sp-date-picker field="fromdate" \newline ng-model="c.from" \newline ng-model-options="\{getterSetter: true\}" \newline sn-include-time="true" \newline sn-disabled="false"\textgreater{}\textless{}/sp-date-picker\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\emph{ sn-include-time property when set to true it will allow to select date and time. and when false it will allow to select only date.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{6.24 cm} x{1.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{FormController -(Widgets)}} \tn % Row 0 \SetRowColor{LightBackground} True if user has not interacted with the form yet. & \seqsplit{`\$pristine`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} True if user has already interacted with the form. & \seqsplit{`\$dirty`} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{spModal - Client}} \tn % Row 0 \SetRowColor{LightBackground} Displays an alert. & \seqsplit{`spModal.alert('Thanks} for the \seqsplit{update').then(function} (answer) \{`\{\{nl\}\} `c.simple = answer;`\{\{nl\}\} `\});` \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} Displays a confirmation message. & \seqsplit{`spModal.confirm("Can} you confirm or deny \seqsplit{this?").then(function(confirmed)} \{`\{\{nl\}\} `c.confirmed = confirmed; // true or false`\{\{nl\}\} `\})` \tn % Row Count 13 (+ 7) % Row 2 \SetRowColor{LightBackground} Opens a modal window using the specified options. & `spModal.open(\{`\{\{nl\}\} `title: 'Give me a name',`\{\{nl\}\} `message: 'What would you like to name it?',`\{\{nl\}\} `input: true,`\{\{nl\}\} `value: c.name`\{\{nl\}\} `\}).then(function(name) \{`\{\{nl\}\} `c.name = name;`\{\{nl\}\} `\})` \tn % Row Count 25 (+ 12) % Row 3 \SetRowColor{white} Displays a prompt for user input. & \seqsplit{`spModal.prompt("Your} name please", \seqsplit{c.name).then(function(name)} \{`\{\{nl\}\} `c.name = name;`\{\{nl\}\} `\})` \tn % Row Count 30 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{The spModal class provides an alternative way to show alerts, prompts, and confirmation dialogs. The SPModal class is available in Service Portal client scripts.}} \newline {\emph{You can use spModal.open() to display a widget in a modal dialog. }} \newline {\bf{{\emph{To use spModal in the client controller ensure that you add the spModal function in the client function}}}} \newline `function(spModal) \{` \newline `/{\emph{ widget controller }}/` \newline `var c =this;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Embed a widget in an HTML template}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{\{\{fa-asterisk\}\} Use the \textless{}widget\textgreater{}\textless{}/widget\textgreater{} element to embed a widget in an HTML template. Pass in the ID of the widget you are trying to embed as a parameter. \newline % Row Count 4 (+ 4) `\textless{}div\textgreater{}` \newline % Row Count 5 (+ 1) ` \textless{}widget id="widget-cool-clock"\textgreater{}\textless{}/widget\textgreater{}` \newline % Row Count 6 (+ 1) `\textless{}/div\textgreater{}` \newline % Row Count 7 (+ 1) \{\{fa-asterisk\}\}If a widget has an option schema, you can define instance options in JSON format. \newline % Row Count 9 (+ 2) `\textless{}widget id="widget-cool-clock" options='\{"zone": "America/Los\_Angeles","title": "San Diego, CA"\}'\textgreater{}``\textless{}/widget\textgreater{}`% Row Count 12 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{spContextManager - Client}} \tn % Row 0 \SetRowColor{LightBackground} Initializes a key and adds widget data as the value. & \seqsplit{`spContextManager.addContext('agent-chat'}, \{` `'approval\_count': 5 ` `\});` \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} Returns each key and associated data object defined by any widget on the page. & \seqsplit{`spContextManager.getContext();`} \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} Returns the widget data associated with a key. & \seqsplit{`spContextManager.getContextForKey('agent-chat'}, \seqsplit{true).then(function(context)} \{` `context = context || \{\};` \seqsplit{`context.approval\_count} = 5;` \seqsplit{`spContextManager.updateContextForKey('agent-chat'}, context);` `\});` \tn % Row Count 20 (+ 11) % Row 3 \SetRowColor{white} Sends data to an existing key. & \seqsplit{`spContextManager.getContextForKey('agent-chat'}, \seqsplit{true).then(function(context)} \{` `context = context || \{\};` \seqsplit{`context.approval\_count} = 5; ` \seqsplit{`spContextManager.updateContextForKey('agent-chat'}, context);` `\});` \tn % Row Count 32 (+ 12) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\emph{Make data from a Service Portal widget available to other applications and services in a Service Portal page. }} \newline {\bf{{\emph{to use the spContextManager, ensure to add this in the function for client controller}}}} \newline `function (\$scope, spContextManager) \{` \newline `var c =this;` \newline `\}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}