Categories:
  1. Service Portal Introduction
  2. Service Portal Training Content
  3. Service Portal Object
  4. Portal Backend Structure
  5. Portal Module & Element
  6. Service Portal Configuration
  7. Build a new Portal
  8. Create Header Menu
  9. Data Preview from Server Side to HTML
  10. HTML Basic
  11. Get Incident Data & Show in a table
  12. Call HTML to Client Script
  13. Call Server Side Script for Action
  14. ServiceNow OOB Widget Provide for Portal
  15. Javascript popup VS SPModal
  16. spUtil – Client Dependency Service Portal
  17. Widget Embedded
  18. Send data from one widget to another
  19. GlideSPScriptable API on Server Side
  20. Angular Template
  21. $location, $timeout, $uibModal & $watch Services
  22. Use HTTP Service or REST Call on ServicePortal
  23. Angular Directive & Angular Filter
  24. Create a custom list widget with pagination, order, and filter
  25. ServiceNow Custom Component(Reference & Date Fields) in Service Portal
  26. Localization
  27. Create Own Theme
  28. Angular Provider & Dependency
  29. Service Portal Additional Details

Data Preview from Server Side to HTML

Server Side Script can query any particular table and that data can be show to to HTML side with nicely HTML & CSS code.

For data server side, use GlideRecord and Script Include to Query the data.

After receiving the data we must be pass store to any variable and that variable data can be set to data.variable_name.

In HTML side use angular js syntax to bind the data- {{data.variable_name}}

Today’s Class Code:

HTML

<div>
<!-- your widget template -->
  Hello {{data.fname}},
  Last task oppend by {{data.task}}
</div>

Server Side Code

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	
	
	var usr = gs.getUserID(); // sys_id
	var grusr = new GlideRecord('sys_user');
	if(grusr.get(usr)){
		data.fname = grusr.getValue('first_name');
		
		var grtask = new GlideRecord('task');
		grtask.addEncodedQuery('opened_by='+grusr.getValue('sys_id'));
		grtask.orderByDesc('sys_created_on');
		grtask.query();
		if(grtask.next()){
			data.task = grtask.getValue('number');
		}
		
	}

})();

Total Views: 1404

One response

  1. The explanation is nice and easy to understand the concepts. However, would like to highlight a pointer.Since it is Service Portal, before passing the values in data object to html/client script, it is suggestible to use glide_record_object.getValue(‘__field_name__’) or getDisplayValue(‘__field_name__’);

Leave a Reply

Your email address will not be published. Required fields are marked *