ArrayUtil API
Merges two arrays |
new ArrayUtil().concat(array1,array2)
|
Searches the array for the element. Returns true if the element exists in the array, otherwise returns false |
new ArrayUtil().contains(array,searchobject)
|
Converts an object to an array. |
new ArrayUtil().convertArray(Object)
|
Finds the differences between two or more arrays |
new ArrayUtil().diff(array1,array2,array n)
|
Returns an array from the object. |
new ArrayUtil().ensureArray(Object)
|
Searches the array for the element. Returns the element index if found, -1 otherwise. |
new ArrayUtil().indexOf(array1, seachelement)
|
Finds the elements common in all arrays. |
new ArrayUtil().intersect(Array a, Array b)
|
Merges two or more arrays (common element is addded once) |
new ArrayUtil().union(Array a, Array b)
|
Removes duplicate items from an array. |
new ArrayUtil().unique(Array a)
|
The syntax of the above APIs can be Like this
var arUtil = new ArrayUtil();
arUtil.unique(array1);
CIUtils
Determine which business services are affected by a specific CI. |
new CIUtils().servicesAffectedByCI(ci_sys_id);
|
Determine which business services are affected by a task. |
new CIUtils().servicesAffectedByTask(taskgliderecord)
|
Sample Usage of the script can be like below
var CIUtil = new CIUtils();
var bsaffected = CIUtil.servicesAffectedByCI(ci_sys_id);
GlideFilter
Compares a specified filter to the contents of a specified GlideRecord. |
GlideFilter.checkRecord(glideRecord, "filterconditions",matchparameter);
|
If the specified filter contains one condition, the method returns true if the record meets the condition of the filter.
matchparameter indicates whether all conditions must be met if the filter parameter contains multiple conditions.
Valid values:
true: all conditions must be met for the method to return true
false: only one of the conditions must be met for the method to return true.
TableUtils
Checks to see if a table exists. |
new TableUtils("TABLENAME").tableExists();
|
Drops a database table. (use with caution) |
new TableUtils().drop("TABLENAME");
|
Drops a database table and cleans up references to the table. |
new TableUtils().dropAndClean("TABLENAME");
|
Drops a database table, all of it's extended tables, and cleans up references to the tables. |
new TableUtils().dropTableAndExtensions("TABLENAME");
|
Returns the base table name from which the table was extended. |
new TableUtils("tablename").getAbsoluteBase();
|
Returns the list of tables that extend a table, includes the base table in array |
new TableUtils("tablename").getAllExtensions();
|
Returns a list of all classes participating in the hierarchy of the specified table. |
new TableUtils("tablename").getHierarchy();
|
Returns the table hierarchy. |
new TableUtils("tablename").getTables();
|
Returnss a list of tables that extend a table. |
new TableUtils("tablename").getTableExtensions();
|
Determines if a table has been extended. |
new TableUtils("tablename").hasExtensions();
|
Determines if a table is a base class, meaning it has no parents and has extensions. |
new TableUtils("tablename").isBaseClass();
|
Determines if the table has no parents and no extensions. |
new TableUtils("tablename").isSoloClass();
|
Use Drop the table function with extreme caution as it will delete the table and the data forever
GlideSysAttachment
Copies attachments from the source record to the target record. |
new GlideSysAttachment().copy(String sourceTable, String sourceID, String targetTable, String targetID)
|
Deletes the specified attachment. |
new GlideSysAttachment().deleteAttachment(attachmentsysID)
|
Returns a GlideRecord containing the matching attachment metadata such as name, type, or size. |
new GlideSysAttachment().getAttachments('<table_name>', '<record_sys_id>');
|
Returns the attachment content as a string. |
new GlideSysAttachment().getContent(GlideRecord sysAttachment)
|
Returns the attachment content as a string with base64 encoding. |
new GlideSysAttachment().getContentBase64( GlideRecord sysAttachment)
|
Inserts an attachment for the specified record using base64 encoded content. |
new GlideSysAttachment().writeBase64( GlideRecord gr, String fileName, String contentType, String content_base64Encoded)
|
SLARepair
Repair the task SLAs associated with the passed-in filter and source table. |
new SLARepair().repairByFilter('filter', 'tablename');
|
Repair the task SLAs associated with the passed in GlideRecord. |
new SLARepair().repairByGlideRecord(glideRecord)
|
Repair the task SLAs associated with the passed in sys_id and source table. |
new SLARepair().repairBySysId('sysId', 'tablename');
|
Enables or disables auditing when running a repair.* |
new SLARepair().setAuditEnabled(true);
|
Enables or disables running a workflow for each of the Task SLA records being repaired. |
new SLARepair().setRunWorkflow(false)
|
Validates the repair request. |
new SLARepair().setValidateOnly(true);
|
The SLARepair API first deletes the existing SLAs and then recreates them from each task's history.
*auditing is set to the value in the property com.snc.sla.repair.audit. You can override this with passing in true to enable or false to disable auditing.
GlideEmailOutbound
Adds the address to either the cc or bcc list. |
email.addAddress('cc/bcc', 'emailaddress1','emailaddress2');
|
Returns the email's subject line. |
|
Returns the email's watermark. |
|
Sets the body of the email. |
email.setBody('bodytext');
|
Sets the sender's address. |
`email.setFrom('emailaddress'); |
Sets the reply to address. |
email.setReplyTo('emailaddress');
|
Sets the email's subject line. |
email.setSubject('emailaddress');
|
GlideSession
Sets a session client value that can be retrieved with getClientData(). |
gs.getSession().putClientData('paramname', 'paramvalue');
|
Determines if the current user is currently logged in. |
'gs.getSession().isLoggedIn()' |
Determines if the current session is interactive. |
'gs.getSession().isInteractive()' |
Gets the name of the session's time zone. |
'gs.getSession().getTimeZoneName()' |
Gets a list of roles for the current user. |
'gs.getSession().getRoles()' |
Gets the session's language code. |
'gs.getSession().getLanguage()' |
Returns a session client value previously set with putClientData(). |
gs.getSession().getClientData('paramname');
|
Clears a session client value previously set with putClientData(). |
gs.getSession().clearClientData('paramname');
|
The GlideSession API allows you to find information about the current session.
var session = gs.getSession();
session.putClientData('cheatsheet', 'OOBAPI');
|
|
CartJS
Adds the request for a catalog item to the current cart. |
new sn_sc.CartJS().addToCart(request);
|
Performs the cart checkout. If the two-step checkout is enabled, returns the order summary. If the two-step checkout is disabled, the cart is submitted and details of the generated request are returned. |
new sn_sc.CartJS().checkoutCart();
|
Deletes the current cart. |
new sn_sc.CartJS().empty();
|
Returns the cart id of the current cart. |
new sn_sc.CartJS().getCartID();
|
Returns the GlideRecord for the cart item (sc_cart_item) in the current cart. |
new sn_sc.CartJS().getCartItems();
|
Gets the sys_id from the sys_user record of the user for whom the cart is requested. |
new sn_sc.CartJS().getRequestedFor();
|
Orders a single item. |
new sn_sc.CartJS().orderNow(request);
|
Specifies if the current user has the required role to edit the Request for field. |
new sn_sc.CartJS().canViewRF();
|
Sets the sys_id in the sys_user record of the user for whom the cart is requested. |
new sn_sc.CartJS().setRequestedFor(sysid)
|
The variable used in the scripts above called 'request' should be a JSON Object which has the details of the catalog items to be added to cart or to order. Sample is below
var item ={
'sysparm_id': '0d08837237153000158bbfc8bcbe5d02', // Catalog item sys_id
'sysparm_quantity': '1',
'variables':{ // Pass the catalog item variables
'carrier': 'at_and_t_mobility',
'data_plan': '500MB',
'duration': 'eighteen_months',
'color': 'slate',
'storage': 'sixtyfour'
}};
TemplatePrinter (Mail Script)
Prints the string to the email body. |
template.print("Incident number - " + current.number + "\n");
|
Adds non-breaking spaces to the email body. |
|
GlideLocale
Returns the GlideLocale object. |
|
Returns the decimal separator. |
var locale = GlideLocale.get(); var dseperatr = locate.getDecimalSeparator()
|
Returns the grouping separator. |
var locale = GlideLocale.get();var groupingSeparator = locale.getGroupingSeparator();
|
GlideRecordUtil
Returns a GlideRecord instance positioned to the given CI sys_id, and of the right class (table). |
new GlideRecordUtil().getCIGR("cisysid");
|
Returns a list of all the fields in the specified GlideRecord. |
new GlideRecordUtil().getFields(gliderecordobject)
|
Returns a GlideRecord instance for the given table, positioned to the given sys_id, and of the right class (table). |
new GlideRecordUtil().getGR("table", "sysID");
|
Returns a Java ArrayList of the ancestors of the given table name. |
new GlideRecordUtil().getTables("tablename")
|
Sets the fields in the specified GlideRecord with the field values contained in the specified hashmap, unless that field name is in the ignore hashmap.* |
var gr = new GlideRecordUtil().getGR("table", "sysid"); var obj = {"fieldname": "fieldvalue"}; var ignore = {"sys_created_by": true}; new GlideRecordUtil().mergeToGR(obj, gr, ignore); gr.update();
|
Populates the given hashmap from the given GlideRecord instance. Each field in the GlideRecord becomes a property in the hashmap.( returns field/value pairs from the GlideRecord) |
var objectToPopulate = {}; var gr = new GlideRecordUtil().getGR("table", "sysid"); var ignore = {"sys_created_on": true, "sys_updated_by": true}; new GlideRecordUtil().populateFromGR(objectToPopulate, gr, ignore);
|
GlideSchedule
Adds a new schedule segment to the current schedule. |
new GlideSchedule().add(startDate, duration)
|
Determines the elapsed time in the schedule between two date time values using the timezone of the schedule or, if that is not specified, the timezone of the session. |
var schedule = new GlideSchedule();schedule.load('schedulesysid');var duration = schedule.duration(startDate, endDate);
|
Retrieves the schedule name. |
new GlideSchedule(sys_id).getName()
|
Determines if the given datetime is within the current schedule. |
new GlideSchedule("schedulesysid").isInSchedule(date);
|
Determines if the current schedule is valid. A schedule is valid if it has at least one schedule span. |
new GlideSchedule("schedulesysid").isValid();
|
Sets the timezone for the current schedule. |
var schedule = new GlideSchedule(); schedule.setTimeZone('US/Pacific');
|
Determines how much time (in milliseconds) until start time of the next schedule item. |
new GlideSchedule('schedulesysID', 'timezone').whenNext(startDate)
|
The scoped GlideSchedule API provides methods for performing operations on GlideSchedule objects, such as adding new schedule segments to a schedule, determining if a datetime is within the schedule, or setting the schedule timezone.
FlowAPI
Cancels a paused or running flow, subflow, or action. |
sn_fd.FlowAPI.startFlow('flowname', inputs);
|
Run an action from a server-side script synchronously. |
sn_fd.FlowAPI.executeAction('flowname', inputs);
|
Run an action from a server-side script synchronously from the current user session without creating execution details or other related records |
sn_fd.FlowAPI.executeActionQuick('flowname', inputs);
|
Runs a Data Stream action synchronously from a server-side script and returns a ScriptableDataStream object. |
sn_fd.FlowAPI.executeDataStreamAction('datastream_name',input,timeout);
|
Run a flow from a server-side script synchronously. |
sn_fd.FlowAPI.executeFlow('flowname', inputs,timeout);
|
Run a flow, subflow, or action from a server-side script synchronously or asynchronously without creating execution details or other related records. |
sn_fd.FlowAPI.executeFlowQuick('flowname', inputs);
|
Run an subflow from a server-side script synchronously. |
var results = sn_fd.FlowAPI.executeSubflow('flowname', inputs);
|
Run a subflow from a server-side script synchronously from the current user session without creating execution details or other related records |
var results = sn_fd.FlowAPI.executeSubflowQuick('flowname', inputs);
|
Build password2 values inside a script step. |
var encrypteddata=sn_fd.GlideActionUtil.setEncryptedOutput(Val);
|
Run an action from a server-side script asynchronously. |
sn_fd.FlowAPI.startAction('flowname', inputs);
|
Run an action from a server-side script asynchronously without creating execution details |
sn_fd.FlowAPI.startActionQuick('flowname', inputs);
|
Run a flow from a server-side script. |
sn_fd.FlowAPI.startFlow('flowname', inputs);
|
Run a flow from a server-side script asynchronously without creating execution details |
sn_fd.FlowAPI.startFlowQuick('flowname', inputs);
|
Run a subflow from a server-side script. |
sn_fd.FlowAPI.startSubflow('flowname', inputs);
|
Run a subflow from a server-side script asynchronously without creating execution details |
sn_fd.FlowAPI.startSubflowQuick('flowname', inputs);
|
Use FlowAPI methods to execute actions, flows, or subflows in server-side scripts using either blocking or non-blocking methods.
|
Created By
https://bibingokuldas.com
Metadata
Comments
SilverSurfer, 15:29 25 Aug 20
Can't download the file without commenting?
Add a Comment
Related Cheat Sheets
More Cheat Sheets by bibingokuldas