Reference Fields with the snRecordPicker Directive

One of the very powerful directives available in Service Portal that we will be covering today is the snRecordPicker. This directive generates a field very similar to a reference field in the platform. This is very useful when creating custom widgets that will be interacting with tables and records in ServiceNow. The Directive: [crayon-66a10f0c9336c567033360/] It supports the following properties: Property Description field a JavaScript object consisting of "displayValue", "value" and "name" table the table to pull records from default-query the query to apply to the table display-field (or display-fields) the display field value-field the value field (usually sys_id) search-fields the fields to search page-size number of records to display in dropdown   To use the snRecordPicker you will also need to create the "field" object in your controller as well as listen for the "field.change" event. The Controller: [crayon-66a10f0c93377088756288/] The Widget: I've created a sample address picker widget that allows the user to select a location, and then retrieves the record from the server and populates several other fields with the information. The widget is available for download here:

Geneva Service Portal – Creating a “Hello World” widget

In this tutorial I create a simple Hello World widget that makes a call to the server to retrieve the "name" of the user based on the "username" entered in the input. This tutorial is specific to the Geneva version of Service Portal. Also in case you missed my big announcement made earlier today: I'm now available for contract work. HTML Template: [crayon-66a10f0ca08ec256324888/] JSON Data Producer: [crayon-66a10f0ca08f7735671910/] Client Script: [crayon-66a10f0ca08f9950412331/]