Category:
Updated on: August 31, 2025  |  0

Server Side Scenarios 3

๐Ÿ”ง Server-Side Scripting: Examples & Scenarios


๐Ÿ”— 6. Integrations

6.1 REST Call from Script Include

ย 
var r = new sn_ws.RESTMessageV2(); r.setHttpMethod('get'); r.setEndpoint('https://api.example.com/assets'); var response = r.execute(); var body = response.getBody(); gs.info(body);

6.2 SOAP Call Example

ย 
var sm = new sn_ws.SOAPMessageV2('MySOAPProfile', 'getDetails'); sm.setStringParameterNoEscape('id', '12345'); var response = sm.execute(); gs.info(response.getBody());

๐Ÿงฉ 7. CMDB & Asset Management

7.1 Ensure Serial Number is Unique (Business Rule)

ย 
var gr = new GlideRecord('cmdb_ci_computer'); gr.addQuery('serial_number', current.serial_number); gr.addQuery('sys_id', '!=', current.sys_id); gr.query(); if (gr.hasNext()) { gs.addErrorMessage("Duplicate Serial Number found!"); current.setAbortAction(true); }

๐Ÿ› ๏ธ 8. Background Scripts

Useful for one-time fixes or bulk updates.

8.1 Update All Incidents with Missing Short Description

ย 
var gr = new GlideRecord('incident'); gr.addNullQuery('short_description'); gr.query(); while (gr.next()) { gr.short_description = "Auto-populated missing description"; gr.update(); }

๐Ÿ“‹ 9. Real-World Scenarios

  1. Incident Management

    • Auto-assign based on Category.

    • Prevent closure without Resolution Notes.

  2. Change Management

    • Restrict scheduling outside maintenance windows.

    • Auto-notify stakeholders when a risky change is submitted.

  3. Problem Management

    • Identify recurring incidents โ†’ auto-create a Problem record.

  4. HRSD

    • Enforce employee record validation before HR Case creation.

  5. CMDB Governance

    • Prevent duplicate CIs.

    • Auto-update relationships based on imports.

Comments

No comments yet.


Log in to post a comment