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

Call Server Side Script for Action

server.update function lifecycle

HTML:

<button ng-click="c.useraction(key.sys_id,'close')">Close Incident</button>

Client Script:

c.useraction = function(id,action){
		if(action == 'open'){
		var url="?id=form&table=incident&sys_id="+id;
		window.open(url,'_blank');
		}else{
			c.data.currentIncident=id;
			c.server.update().then(function(){
				c.data.currentIncident="";
			})
			//input = data
		}
	}

Server Side Script

if(input && input.currentIncident){
		gs.addInfoMessage('Line 18');
		var grupdate = new GlideRecord('incident');
		if(grupdate.get(input.currentIncident)){
			grupdate.state = 6;
			grupdate.update();
		}
	}
	
	gs.addInfoMessage('Line 4');
	data.Inc =[];
	var grInc = new GlideRecord('incident');
	grInc.addEncodedQuery('caller_id='+gs.getUserID());
	grInc.query();
	while(grInc.next()){
		var json ={};
		json.number = grInc.number.toString();
		json.short_description = grInc.short_description.toString();
		json.assignment_group = grInc.getDisplayValue('assignment_group');
	  json.sys_id = grInc.getValue('sys_id');
		json.state=grInc.getDisplayValue('state');
		data.Inc.push(json);
	}

Total Views: 1429

2 Responses

Leave a Reply

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