Click the Preview Update Set button in the header.The name will be "Service Portal Global Objects Demo" Click on the newly uploaded update set in the list of Retrieved Update Sets.Click "Choose File", location the downloaded update set from the KB article and press the "Upload" button.Click on the Related Link "Import Update Set from XML" at the bottom of the page.Click on "Retrieved Update Sets" in the Application Navigator. To import the update set to your test instance: Download the update set and following the directions below. To follow along with the examples in this article, you'll need to first add the Global Objects Demo Widget to your developer instance. Resume JavaScript execution with the button to the right of the code editor window. Hover the mouse over the "data" in line 15 to inspect the response. Notice that JavaScript execution stops directly at line 15. Save the widget and refresh the preview pane. In the Client Script of the widget, add the code debugger at line 23. Adding the debugger function is like inserting a break point into your code allowing you to step through the code line by line. The debugger function can be used in the Client Script of the widget but not the Server Script. Using the inbuilt debugger function in Chrome and Firefox The input object is undefined and the data object is printed to the console. Refresh the preview pane and you'll notice the following result in the console: Open the JavaScript console in Chrome developer tools. If you look at line 3 and line 16 of the Server Script of the Global Objects Demo Widget, you'll notice that the "input" and "data" objects are logged to the console. The fact that it works in the Service Script as well is a great advantage! I can't think of anywhere else in the ServiceNow platform where you can log to the JavaScript console from server-side JavaScript. This technique will work in the Client Script of the widget and also in the Server Script. The console.log() function will log data to the JavaScript console in the browser. Basic Techniques Logging to the JavaScript console To run the examples in the article you will need to see section Running the Examples at the end of the article to get setup. Service Portal fundamentals: AngularJS scopesĪll examples in this article are run on a widget called "Global Objects Demo Widget". If you are completely new to Service Portal and are starting from scratch, you may want to have a look at these resources below before you start running the examples from this article. The techniques in this article are a compilation of techniques gathered from currently available ServiceNow resources and new techniques which are documented here for the first time. For more complicated scenarios, a firm grasp of the Advanced Techniques may be required. The techniques range in complexity from simply logging to the console to pulling the strings of your widget from the JavaScript console like a puppet master! In most situations, an understanding of the Basic Techniques section will suffice. This article attempts to make your job just a little bit easier by setting out a standard set of Service Portal Widget debugging techniques and is intended both for informational and training purposes. Normal ServiceNow function to output text to the syslog database table as an ERROR.Debugging Service Portal Widgets - Basic and Advanced Techniquesĭeveloping on ServiceNow's Service Portal can be tricky sometimes, especially if you are new to web development or new to AngularJS. Normal ServiceNow function to output text to the syslog database table as a WARNING. Normal ServiceNow function to output text to the syslog database table. Similar to gs.addInfoMessage(String) but only outputs if user has sp_admin role or is impersonating. Can log server-side JavaScript Objects and Strings. When used in the Server Script, can log server-side JavaScript Objects and Strings Native to Chrome and Firefox to set a browser breakpoint, letting an admin step through script line by line Uses Angular json filter to display content of data object in an easy-to-read fashion When used in the Client Controller, this command is native to the browser.Īdd this to the template.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |