Posts

Showing posts from March, 2019

Background Scripts

BACKGROUND SCRIPT CODE VAULT RECORD QUERIES ACTIVE REQUESTS WITHOUT REQUESTED ITEMS (function() { var grRequest = new GlideRecord("sc_request"); grRequest.addEncodedQuery("active=true"); grRequest.query(); gs.print('Active Requests without Requested Items :('); while (grRequest.next()) { var gaRequestedItem = new GlideAggregate("sc_req_item"); gaRequestedItem.addQuery("request",grRequest.sys_id); gaRequestedItem.addAggregate('COUNT'); gaRequestedItem.query(); var req = 0; if (gaRequestedItem.next()) { req = gaRequestedItem.getAggregate('COUNT'); if (req == 0) { gs.print(grRequest.number); } } } })(); DISTINCT OPERATING SYSTEMS OF CIS (function() { var gaServer = new GlideAggregate('cmdb_ci_server'); //GlideAggregate query gaServer.addAggregate('count'); //Count aggregate (only necessary for a count of items of each OS) gaServer.orderByAggregate('count'); //Count aggregate ordering gaServe...

SNow - Clean Architecture

Clean Architecture with ServiceNow Introduction The following set of rules is aimed to provide a maintainable, extendable and understandable architecture for any solution within service now. They are kept as short as possible to allow for a one page document. Please share your thoughts and feedback, as well as your critique. 1 Script Includes are for Data Manipulation Don’t save. Don’t update. Don’t insert. Don’t delete. In fact: Script Includes don’t. They provide. 2 Business Rules are for Data Transformation Do save. Do update. Do insert. Do delete. In fact: Business Rules do, but won’t think. Therefore, make Script Includes the brain of Business Rules. 3 Client scripts are for displaying data What do they display? Data! Where do they get it from? Queries! Do they think? No! Do they do? No! But what are they there for? To display data. That’s it. 4 Workflows are a succession of Business Rules Follow the same principles! They do, but won’t think. Make Sc...