User Tools

Site Tools


k

Welcome to our SNOW INFO PAGE Section K


Key Concepts

- See the following file for Syntax Editor Macros containing code snippets of all of the following Client Side and Server Side concepts:

syntax_editor_macro (sys_updated_by!=glide.maint^ORsys_updated_by=NULL).xml 

Key Concept - Client - Generating Messages

- Generating Messages for User Feedback and for Debugging… - Use the alert() function to show a prominent and blocking modal dialog which must be explicitly dismissed for execution to continue. - Display a message to the user from Client code using g_form.addInfoMessage() or g_form.addErrorMessage() - Use g_form.addDecoration() to show a small graphic symbol by a form field label. A mouse-over popup hint may be included, and a color may be specified. - Use g_form.flash() to display a flashing colored background box behind a form field label. - Use the confirm() function to display a modal popup dialog to get a response (OK or Cancel) from the user before continuing execution. - Use the jslog() function to write a message to the web browser console. Use this rather than console.log(). - Screenshot


Key Concept - Client - Glide Ajax Method

- From client side code, to invoke server side code asynchronously, instantiate a custom GlideAjax object. - Use the addParam() function, and by convention, the parameter named “sysparm_name” to specify which server side function to invoke. - Additional arbitrary parameters may also be specified with addParam(); In this example “sysparm_Prefix”. - Use getXMLAnswer() to invoke the server-side function and specify a callback function; in this example “finishClientSideWorkONE”. - Use a direct parameter in your callback function to make use of data returned by the server; in this case the parameter is named “answerFromServer”.


Key Concept - Client - GlideRecord Database Access

- Use Client Side GlideRecord get() method to grab data from the server in a Blocking fashion. - Use Client Side Glide Record query() method to grab data from the server in an Asynchronous fashion. - Use JavaScript try{} and catch(){} blocks to ensure continued execution if there is an unhandled exception. - IMPORTANT: DO NOT BELIEVE THAT GLIDERECORD WORKS CLIENT-SIDE IN THE SERVICE PORTAL.


Key Concept - Client - GlideRecord GetReference() Database Access

- Simple function for getting All of the data about a particular reference field from the server. Example here is asynchronous. Can be done synchronously also. - Screenshot


Key Concept - Client - Reusable Script

- Declare a function in table sys_ui_script to make it reusable in Platform UI client side code. Be sure to change UI Type to Desktop and check the Global checkbox. - Will NOT be accessible via the Portal, Mobile, or Agent Workspace user interfaces. : ( - Screenshot


Key Concept - Client - Scratchpad Database Access

- Use the g_scratchpad object from client side code to get access to Any database value, even those not represented by form fields. - Retrieve a basic value from a form with g_form.getValue()… - Set a basic value on a form with g_form.setValue()… - Screenshot


Key Concept - Client - Try Block

- Macro: c_try - Catches errors such as the following: 1) ReferenceError: FunctionXXX is not defined 2) TypeError: g_form.FunctionXXX is not a function 3) TypeError: Cannot read properties of null (reading 'MyFunction') - Screenshot


Key Concept - Server - Ajax Function Definition

- Declare a class which extends from AbstractAjaxProcessor to define custom server-side functions callable from the Client. - Screenshot


Key Concept - Server - Current and Previous GlideRecord Objects

- “Before Update” and “Before Insert” business rules provide access to “current” and “previous” GlideRecord parameters. - The “current” object may be used to change field values before the actual database update. - The “previous” object, in some business rules, gives the values of all fields as they were when the record was initially loaded from the database, and before any changes were made in the UI on the client. - Screenshot


Key Concept - Server - Event Definition and Triggering

- Macro: s_event - Screenshot


Key Concept - Server - Excel File Processing

- Use the sn_impex.GlideExcelParser() class to parse any attached excel file! - Screenshot


Key Concept - Server - Generating Messages

- Push messages from the server up to the client form using gs.addInfoMessage() or gs.addErrorMessage(). - Write to table “syslog” with gs.info(), gs.warn(), or gs.error(). - Write to table “syslog” but with a custom Data Source using gs.log(), gs.logWarning, or gs.logError(); here the custom data source is “Phoenix”. - Screenshot


Key Concept - Server - GlideRecord Database Access

- Access database records by instantiating a GlideRecord object on a particular table. - Use addQuery() to add one or more “where” type conditions to limit the records matched. - You may also use addEncodedQuery() to add a query copied from a ListView filter. - Optionally, order the records returned using orderBy() or orderByDesc() functions. - Optionally, limit the number of records returned, if necessary, using setLimit(). - Use the query() and next() functions to actually retrieve records from the database. - Access returned record fields using .fieldName or using the getValue() function. - Alternatively, query the database in one line using the get() method. With get(), there is no need for the addQuery(), query(), or next() functions.


Key Concept - Server - GlideRecord Database Insert

- Use the GlideRecord initialize() function to obtain a new record number. - Use the GlideRecord insert() function to save the new record to the database. - Screenshot


Key Concept - Server - JavaScript Arrays (applies to Client code also)

- Screenshot


Key Concept - Server - JavaScript Objects (applies to Client code also)

- Screenshot


Key Concept - Server - Library Class Definition

- Such classes would often appear in a Script Include record. - Use the .prototype keyword and the Class.create() method to declare a regular library class containing various (non-AJAX) utility functions. - Use the this keyword to declare and utilize instance variables.


Key Concept - Server - Library Class and Function Usage

- To call a script include library method from other server-side code, instantiate the class using the new keyword, then simply invoke named functions. - To call a script include Classless library function from other server-side code, simply invoke the function name directly. - Screenshot


Key Concept - Server - Library Function Definition

- Use the function keyword, and a separate Script Include record, to easily declare a server-side Classless Function. - Check the Client callable function, to make the function callable from the Client. - Screenshot


Key Concept - Server - Mail Script

- For injecting values and links into Notification message bodies. - A mail script is built within the function runMailScript(); use the function template.print() to output content back to a notification which has invoked the script. The mail script has access to many important objects such as “current” and “event”. These are passed in automatically to the runMailScript() function. - Screenshot


Key Concept - Server - Scratchpad Population

- Normally client side code has quick access to only those values which actually appear on a form, not to all values from the database; to proactively surface other database values to the client, a special object called g_scratchpad may be used. When a form is loaded, “display” type business rules are executed, and these may populate a special object called g_scratchpad with data. This is faster than relying on AJAX, which requires additional round trips to the Server. - Screenshot


Key Concept - Server - 'Set Redirect URL' Function

- Use the Debug Now UI Action to debug scripts from table sysauto_script (“Scheduled Script Executions”) with syntax highlighting and breakpoint capabilities. - Use action.setRedirectURL(current) in a UI Action, to keep the user on the very same web page after any UI action is executed.


Key Concept - Server - Try Block

- Catches errors such as the following: 1) ReferenceError: FunctionXXX is not defined 2) TypeError: g_form.FunctionXXX is not a function 3) TypeError: Cannot read properties of null (reading 'MyFunction') - Screenshot


Knowledge Management v3 (KM)

- Takeaway Knowledge Bases help organize information and make it widely accessible. A typical Knowledge Base article might be a Policy, Self-Help Document, or Technical Note on some module or integration. Knowledge bases have Categories and Subcategories, and Facets allow a user to filter out irrelevant articles. Optionally, a feature known as Social Q&A can be enabled to allow users to ask questions, answer questions, vote, and mark answers as correct. Tags are keywords which may be configured to match articles to search terms a user may type in. Templates may be setup for uniform article creation and Knowledge Blocks may be saved to allow an author to easily add a common chunk of text to an article. A technology called WebDev allows external articles to show up in the ServiceNow search results. Word documents may be easily imported. Users may Flag articles which need attention. Knowledge Bases may be restricted by role. Video - Getting Started with Knowledge Management v3 Video - How to Control Knowledge Access Through User Criteria - The knowledge homepage displays only those Knowledge Bases the user has access to. - Categories and Subcategories are now specific to Knowledge Bases. - Hierarchy can be any number of levels deep. - A “Publish” and a “Retire” workflow may be assigned to each KB. For example, some workflows may require approvals. - Access to knowledge articles is controlled at the Knowledge Base level via the following lists: Can Read, Can Contribute, Cannot Read, Cannot Contribute.

  1. User criteria area added to these lists.

- User Criteria * - Replaces Access Controls and Roles, to determine who can view and create Knowledge content. - Called “User” criteria, because conditions are defined which are evaluated against User records. - Allows a knowledge manager to implement and modify security without a Sys Admin's involvement. - User Criteria allow you to control who can and cannot read or contribute to a knowledge base, using all of the following variables:

	Company
	Department
	Group
	Location
	User
	Role
- User Criteria has its own Filter Navigator module.
- Script is available for making User Criteria even more advanced.

- If an article has No user criteria selected, the article is available to all users who have access to that knowledge base, based on the user criteria for the knowledge base. - KB user criteria Restrictions override article-level user criteria. - To export your Favorites, go to “sys_ui_bookmark.list”, filter on the records where the User column has your ID. Then use Export XML Then Import the XML on the Target system. Then log out and log back on the Target system. - KBs organize knowledge by general topic areas. KBs also help to control user access, and help with organization. - Common examples of knowledge articles include policies, self-help tips, troubleshooting, and resolution steps. - Facets are different ways of filtering, for example, by Knowledge Base, or by Category. - A user can Flag an article as missing some information or needing attention. - Flagging an article is a way to privately suggest revisions to the knowledge manager. - Social Q&A: - If “Social Q&A” is active, for a KB, you can ask questions, and respond to questions from other users. You can also vote on questions and answers. - Social Q&A may be turned On or Off for individual KBs. - An Answer to a question may be marked as Correct by the KB owner or Question owner. This gives the Answer a green checkmark. - An article author may add tags (keywords) to an article to help other users find the article (or question). - Templates may be setup for knowledge article creation. - Knowledge blocks allow you to add common chunks of text into the article body. - Using a technology called “WebDev”, ServiceNow can integrate with outside tools such as SharePoint so external articles may appear in search results. - There may be multiple KB's. Not all users will have access to all Knowledge Bases. - The KB manager may select Featured Articles which appear prominently in the KB. - “Most Useful” ranks articles by users. - Each KB has its own Categories. There may also be Subcategories. In this way, the user can Browse, as opposed to Searching. - Articles have “PermaLinks” which may be used to share the article with others. - You can create Knowledge articles easily by importing Microsoft Word documents. - The Import feature works very well from Microsoft Word, and preserves most formatting. - You can “Flag” a knowledge article, and point out a problem with it, or an omission. (Not displayed to other users, like comments.)


Knowledge Article On The Fly Search

- Record Producer defines a Variable of type Custom. - The Variable, on the Type Specifications tab, points to a Macro (“cxs_rp_search”). - A “Record Producer Configuration record” defines how the Search function should work on a specific record producer form.

  1. Tells which variable on the Record Producer to attach to.
  2. Tells what text to show for the Header of the search results.
  3. Specifies a “Search Context” object, which controls the details of how the search will function.
  4. Specifies one or more Filter Configuration objects

- Filter Configuration (cxs_rp_fltr_config) object.

  1. Allows you to add an additional filter, in script, to be applied to the associated search objects. Example:

(function(current, query_table){

		query_table.addActiveQuery();
		query_table.addEncodedQuery("kb_knowledge_base=b8ec3904db4eb810a83e05d2ca9619a2"); //Search this KB only.
		return query_table.getEncodedQuery();

})(current, query_table); - “Search Context” (cxs_context_config) object.

  1. Specifies whether or not Wildcard searches will be allowed.
  2. Specifies whether or not the user will need to Tab Out of the field before search results are shown.
  3. Specifies a “Searcher” object.

- “Searcher” (csx_searcher_config) object.

  1. Specifies a list of “Search Resource” objects.

- “Search Resource Config” (cxs_search_res_config) object.

  1. Specifies a Table
  2. Specifies Conditions (query)
  3. Specifies an Order.
  4. Specifies a single “Search Resource” object.
  5. Specifies additional properties such as Sort Order.

- “Available Search Resource” (v_cxs_search_resource) object.

  1. Defines an object which knows how to participate in Search. Example:

Name: “KnowledgeSearch Resource” Resource ID: com.snc.contextual_search.search_resource.KnowledgeSearchResource Java Class: com.snc.knowledge3.search_resource.KnowledgeSearchResource


Knowledge Approval Management

// Set the variable 'answer' to '', 'approved' or 'rejected' to indicate the approval status for this approval.  When called, the following information is available:
//
//    counts.total = total number of users that are part of this approval
//    counts.approved = # of users that approved so far
//    counts.rejected = # of users that rejected so far
//    counts.requested = # of users that are pending approval
//    counts.not_requested = # of users that are not pending approval
//    counts.not_required = # of users that approval is not required
//
if (counts.approved == 1)
	{
		answer = 'approved';
	}
	

Key Store

- Keystores and truststores are repositories that contain cryptographic artifacts like certificates and private keys that are used for cryptographic protocols such as TLS. - A place (store) to house private keys. - Contains private and sensitive information. - Used to provide credentials to others. - A Java Keystore (JKS) is a common keystore (or truststore) type that is used for Java environments. - A password protected file that sits on the same file system as a running application.

k.txt · Last modified: 11/21/2023 08:54 by johnsonjohn