From b1cf17e7969f20a792a443c2205e73ee9fae3d7a Mon Sep 17 00:00:00 2001 From: John Caruso Date: Sun, 24 Mar 2019 16:13:36 -0500 Subject: [PATCH 1/6] Add ServiceNow London type definitions --- types/servicenow-london/Class.d.ts | 8 + .../GlideDBFunctionBuilder.d.ts | 189 ++++ types/servicenow-london/GlideDate.d.ts | 154 +++ types/servicenow-london/GlideDateTime.d.ts | 833 ++++++++++++++++ types/servicenow-london/GlideDuration.d.ts | 160 ++++ .../servicenow-london/GlideEmailOutbound.d.ts | 90 ++ types/servicenow-london/GlideFilter.d.ts | 3 + types/servicenow-london/GlideLocale.d.ts | 5 + .../servicenow-london/GlidePluginManager.d.ts | 3 + .../GlideRecordOperation.d.ts | 1 + types/servicenow-london/GlideSchedule.d.ts | 167 ++++ .../GlideScopedEvaluator.d.ts | 95 ++ .../GlideScriptedProcessor.d.ts | 5 + .../GlideSecureRandomUtil.d.ts | 6 + .../GlideServletRequest.d.ts | 11 + .../GlideServletResponse.d.ts | 5 + types/servicenow-london/GlideSession.d.ts | 13 + types/servicenow-london/GlideStringUtil.d.ts | 16 + .../servicenow-london/GlideSysAttachment.d.ts | 26 + types/servicenow-london/GlideSystem.d.ts | 90 ++ types/servicenow-london/GlideTime.d.ts | 171 ++++ types/servicenow-london/GlideUser.d.ts | 16 + types/servicenow-london/QueryOperator.d.ts | 15 + types/servicenow-london/RESTAPIRequest.d.ts | 13 + .../servicenow-london/RESTAPIRequestBody.d.ts | 9 + types/servicenow-london/RESTAPIResponse.d.ts | 12 + .../RESTAPIResponseStream.d.ts | 6 + types/servicenow-london/RESTMessageV2.d.ts | 581 +++++++++++ types/servicenow-london/RESTResponseV2.d.ts | 188 ++++ types/servicenow-london/RenderProperties.d.ts | 13 + types/servicenow-london/SOAPMessageV2.d.ts | 31 + types/servicenow-london/SOAPResponseV2.d.ts | 14 + .../ScopedElementDescriptor.d.ts | 227 +++++ .../servicenow-london/ScopedGlideElement.d.ts | 447 +++++++++ .../servicenow-london/ScopedGlideRecord.d.ts | 898 ++++++++++++++++++ .../ScopedQueryCondition.d.ts | 72 ++ types/servicenow-london/Workflow.d.ts | 97 ++ types/servicenow-london/XMLDocument2.d.ts | 13 + types/servicenow-london/XMLNode.d.ts | 11 + types/servicenow-london/XMLNodeIterator.d.ts | 4 + types/servicenow-london/index.d.ts | 62 ++ types/servicenow-london/test/Class.ts | 11 + .../test/GlideDBFunctionBuilder.ts | 75 ++ types/servicenow-london/test/GlideDate.ts | 18 + types/servicenow-london/test/GlideDateTime.ts | 100 ++ types/servicenow-london/test/GlideDuration.ts | 46 + .../test/GlideEmailOutbound.ts | 21 + types/servicenow-london/test/GlideFilter.ts | 10 + types/servicenow-london/test/GlideLocale.ts | 15 + .../test/GlidePluginManager.ts | 18 + types/servicenow-london/test/GlideSchedule.ts | 62 ++ .../test/GlideScopedEvaluator.ts | 34 + .../test/GlideScriptedProcessor.ts | 16 + .../test/GlideSecureRandomUtil.ts | 12 + .../test/GlideServletRequest.ts | 26 + .../test/GlideServletResponse.ts | 10 + types/servicenow-london/test/GlideSession.ts | 64 ++ .../servicenow-london/test/GlideStringUtil.ts | 85 ++ .../test/GlideSysAttachment.ts | 1 + types/servicenow-london/test/GlideSystem.ts | 211 ++++ types/servicenow-london/test/GlideTime.ts | 46 + types/servicenow-london/test/GlideUser.ts | 59 ++ .../servicenow-london/test/RESTAPIRequest.ts | 22 + .../test/RESTAPIRequestBody.ts | 33 + .../servicenow-london/test/RESTAPIResponse.ts | 28 + .../test/RESTAPIResponseStream.ts | 17 + types/servicenow-london/test/RESTMessageV2.ts | 106 +++ .../servicenow-london/test/RESTResponseV2.ts | 22 + types/servicenow-london/test/SOAPMessageV2.ts | 28 + .../servicenow-london/test/SOAPResponseV2.ts | 20 + .../test/ScopedElementDescriptor.ts | 19 + .../test/ScopedGlideElement.ts | 13 + .../test/ScopedGlideRecord.ts | 400 ++++++++ .../test/ScopedQueryCondition.ts | 26 + types/servicenow-london/test/Workflow.ts | 134 +++ types/servicenow-london/test/XMLDocument2.ts | 153 +++ types/servicenow-london/test/XMLNode.ts | 137 +++ .../servicenow-london/test/XMLNodeIterator.ts | 36 + types/servicenow-london/tsconfig.json | 97 ++ types/servicenow-london/tslint.json | 12 + 80 files changed, 7023 insertions(+) create mode 100644 types/servicenow-london/Class.d.ts create mode 100644 types/servicenow-london/GlideDBFunctionBuilder.d.ts create mode 100644 types/servicenow-london/GlideDate.d.ts create mode 100644 types/servicenow-london/GlideDateTime.d.ts create mode 100644 types/servicenow-london/GlideDuration.d.ts create mode 100644 types/servicenow-london/GlideEmailOutbound.d.ts create mode 100644 types/servicenow-london/GlideFilter.d.ts create mode 100644 types/servicenow-london/GlideLocale.d.ts create mode 100644 types/servicenow-london/GlidePluginManager.d.ts create mode 100644 types/servicenow-london/GlideRecordOperation.d.ts create mode 100644 types/servicenow-london/GlideSchedule.d.ts create mode 100644 types/servicenow-london/GlideScopedEvaluator.d.ts create mode 100644 types/servicenow-london/GlideScriptedProcessor.d.ts create mode 100644 types/servicenow-london/GlideSecureRandomUtil.d.ts create mode 100644 types/servicenow-london/GlideServletRequest.d.ts create mode 100644 types/servicenow-london/GlideServletResponse.d.ts create mode 100644 types/servicenow-london/GlideSession.d.ts create mode 100644 types/servicenow-london/GlideStringUtil.d.ts create mode 100644 types/servicenow-london/GlideSysAttachment.d.ts create mode 100644 types/servicenow-london/GlideSystem.d.ts create mode 100644 types/servicenow-london/GlideTime.d.ts create mode 100644 types/servicenow-london/GlideUser.d.ts create mode 100644 types/servicenow-london/QueryOperator.d.ts create mode 100644 types/servicenow-london/RESTAPIRequest.d.ts create mode 100644 types/servicenow-london/RESTAPIRequestBody.d.ts create mode 100644 types/servicenow-london/RESTAPIResponse.d.ts create mode 100644 types/servicenow-london/RESTAPIResponseStream.d.ts create mode 100644 types/servicenow-london/RESTMessageV2.d.ts create mode 100644 types/servicenow-london/RESTResponseV2.d.ts create mode 100644 types/servicenow-london/RenderProperties.d.ts create mode 100644 types/servicenow-london/SOAPMessageV2.d.ts create mode 100644 types/servicenow-london/SOAPResponseV2.d.ts create mode 100644 types/servicenow-london/ScopedElementDescriptor.d.ts create mode 100644 types/servicenow-london/ScopedGlideElement.d.ts create mode 100644 types/servicenow-london/ScopedGlideRecord.d.ts create mode 100644 types/servicenow-london/ScopedQueryCondition.d.ts create mode 100644 types/servicenow-london/Workflow.d.ts create mode 100644 types/servicenow-london/XMLDocument2.d.ts create mode 100644 types/servicenow-london/XMLNode.d.ts create mode 100644 types/servicenow-london/XMLNodeIterator.d.ts create mode 100644 types/servicenow-london/index.d.ts create mode 100644 types/servicenow-london/test/Class.ts create mode 100644 types/servicenow-london/test/GlideDBFunctionBuilder.ts create mode 100644 types/servicenow-london/test/GlideDate.ts create mode 100644 types/servicenow-london/test/GlideDateTime.ts create mode 100644 types/servicenow-london/test/GlideDuration.ts create mode 100644 types/servicenow-london/test/GlideEmailOutbound.ts create mode 100644 types/servicenow-london/test/GlideFilter.ts create mode 100644 types/servicenow-london/test/GlideLocale.ts create mode 100644 types/servicenow-london/test/GlidePluginManager.ts create mode 100644 types/servicenow-london/test/GlideSchedule.ts create mode 100644 types/servicenow-london/test/GlideScopedEvaluator.ts create mode 100644 types/servicenow-london/test/GlideScriptedProcessor.ts create mode 100644 types/servicenow-london/test/GlideSecureRandomUtil.ts create mode 100644 types/servicenow-london/test/GlideServletRequest.ts create mode 100644 types/servicenow-london/test/GlideServletResponse.ts create mode 100644 types/servicenow-london/test/GlideSession.ts create mode 100644 types/servicenow-london/test/GlideStringUtil.ts create mode 100644 types/servicenow-london/test/GlideSysAttachment.ts create mode 100644 types/servicenow-london/test/GlideSystem.ts create mode 100644 types/servicenow-london/test/GlideTime.ts create mode 100644 types/servicenow-london/test/GlideUser.ts create mode 100644 types/servicenow-london/test/RESTAPIRequest.ts create mode 100644 types/servicenow-london/test/RESTAPIRequestBody.ts create mode 100644 types/servicenow-london/test/RESTAPIResponse.ts create mode 100644 types/servicenow-london/test/RESTAPIResponseStream.ts create mode 100644 types/servicenow-london/test/RESTMessageV2.ts create mode 100644 types/servicenow-london/test/RESTResponseV2.ts create mode 100644 types/servicenow-london/test/SOAPMessageV2.ts create mode 100644 types/servicenow-london/test/SOAPResponseV2.ts create mode 100644 types/servicenow-london/test/ScopedElementDescriptor.ts create mode 100644 types/servicenow-london/test/ScopedGlideElement.ts create mode 100644 types/servicenow-london/test/ScopedGlideRecord.ts create mode 100644 types/servicenow-london/test/ScopedQueryCondition.ts create mode 100644 types/servicenow-london/test/Workflow.ts create mode 100644 types/servicenow-london/test/XMLDocument2.ts create mode 100644 types/servicenow-london/test/XMLNode.ts create mode 100644 types/servicenow-london/test/XMLNodeIterator.ts create mode 100644 types/servicenow-london/tsconfig.json create mode 100644 types/servicenow-london/tslint.json diff --git a/types/servicenow-london/Class.d.ts b/types/servicenow-london/Class.d.ts new file mode 100644 index 0000000000..085f14edb8 --- /dev/null +++ b/types/servicenow-london/Class.d.ts @@ -0,0 +1,8 @@ +declare const Class: { + /** + * `Class.create` creates a class and returns a constructor function for instances of the class. + * Calling the constructor function (typically as part of a `new` statement) will invoke the + * class's `initialize` method. + */ + create: () => () => void; +}; diff --git a/types/servicenow-london/GlideDBFunctionBuilder.d.ts b/types/servicenow-london/GlideDBFunctionBuilder.d.ts new file mode 100644 index 0000000000..c2c561b60c --- /dev/null +++ b/types/servicenow-london/GlideDBFunctionBuilder.d.ts @@ -0,0 +1,189 @@ +declare class GlideDBFunctionBuilder { + /** + * Instantiates a GlideDBFunctionBuilder object. + * + * @example + * + * var builder = new GlideDBFunctionBuilder(); + */ + constructor(); + + /** + * Adds the values of two or more integer fields. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myAddingFunction = functionBuilder.add(); + * myAddingFunction = functionBuilder.field('order'); + * myAddingFunction = functionBuilder.field('priority'); + * myAddingFunction = functionBuilder.build(); + */ + add(): GlideDBFunctionBuilder; + + /** + * Builds the database function defined by the GlideDBFunctionBuilder object. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myAddingFunction = functionBuilder.add(); + * myAddingFunction = functionBuilder.field('order'); + * myAddingFunction = functionBuilder.field('priority'); + * myAddingFunction = functionBuilder.build(); + * gs.print(myAddingFunction); + */ + build(): string; + + /** + * Concatenates the values of two or more fields. + * Use the `field(String field)` method to define fields on which the operation is performed. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myConcatFunction = functionBuilder.concat(); + * myConcatFunction = functionBuilder.field('short_description'); + * myConcatFunction = functionBuilder.field('caller_id.name'); + * myConcatFunction = functionBuilder.build(); + */ + concat(): GlideDBFunctionBuilder; + + /** + * Defines a constant value to use in the function. If used with the `dayofweek()` method, the + * string defines whether to use Sunday or Monday as the first day of the week. + * + * @param constant A constant value used in a function. + * + * When used with the `dayofweek()` method, the value defines whether the week starts on a Sunday or + * Monday. + * + * - 1: Week begins on Sunday. + * - 2: Week begins on Monday. + * + * This definition enables the `dayofweek()` method to return the correct day of the week from a + * given date. If a value other than 1 or 2 is provided, the `dayofweek()` method uses Sunday as + * the first day of the week. + */ + constant(constant: string): GlideDBFunctionBuilder; + + /** + * Determines the duration using a given start date/time and end date/time. + * Use the `field(String field)` method to define start and end date/time fields. + */ + datediff(): GlideDBFunctionBuilder; + + /** + * Returns an integer representing the day of the week for a given date. + * + * @returns If the first day of the week is set to Sunday in the constant(String + * constant) method, return values are associated with the following days + * of the week: + * + * - 1: Sunday + * - 2: Monday + * - 3: Tuesday + * - 4: Wednesday + * - 5: Thursday + * - 6: Friday + * - 7: Saturday + * + * If the first day of the week is set to Monday: + * + * - 1: Monday + * - 2: Tuesday + * - 3: Wednesday + * - 4: Thursday + * - 5: Friday + * - 6: Saturday + * - 7: Sunday + * + * If a value other than 1 or 2 is provided in the `constant(String constant)` method, the + * `dayofweek()` method uses Sunday as the first day of the week. + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var dayOfWeekFunction = functionBuilder.dayofweek(); + * dayOfWeekFunction = functionBuilder.field('opened_at'); + * dayOfWeekFunction = functionBuilder.constant('2'); + * dayOfWeekFunction = functionBuilder.build(); + * + * var gr = new GlideRecord('incident'); + * gr.addFunction(dayOfWeekFunction); + * gr.query(); + * while(gr.next()) + * gs.log(gr.getValue(dayOfWeekFunction)); + * + */ + dayofweek(): GlideDBFunctionBuilder; + + /** + * Divides the value of one integer field by another. + * Use the `field(String field)` method to define fields on which the operation is performed. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myDivideFunction = functionBuilder.divide(); + * myDivideFunction = functionBuilder.field('order'); + * myDivideFunction = functionBuilder.field('priority'); + * myDivideFunction = functionBuilder.build(); + */ + divide(): GlideDBFunctionBuilder; + + /** + * Defines a field on which a SQL operation is performed. + * + * @param field The field on which you are performing the SQL operation. + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myAddingFunction = functionBuilder.add(); + * myAddingFunction = functionBuilder.field('order'); + * myAddingFunction = functionBuilder.field('priority'); + * myAddingFunction = functionBuilder.build(); + */ + field(field: string): GlideDBFunctionBuilder; + + /** + * Determines the number of code units in a field. + * Use the `field(String field)` method to define fields on which the operation is performed. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myLengthFunction = functionBuilder.length(); + * myLengthFunction = functionBuilder.field('short_description'); + * myLengthFunction = functionBuilder.build(); + * + */ + length(): GlideDBFunctionBuilder; + + /** + * Multiplies the values of two integer fields. + * Use the `field(String field)` method to define fields on which the operation is performed. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myMultiplyFunction = functionBuilder.multiply(); + * myMultiplyFunction = functionBuilder.field('order'); + * myMultiplyFunction = functionBuilder.field('priority'); + * myMultiplyFunction = functionBuilder.build(); + */ + multiply(): GlideDBFunctionBuilder; + + /** + * Subtracts the value of one integer field from another. + * Use the `field(String field)` method to define fields on which the operation is performed. + * + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var mySubtractFunction = functionBuilder.subtract(); + * mySubtractFunction = functionBuilder.field('order'); + * mySubtractFunction = functionBuilder.field('priority'); + * mySubtractFunction = functionBuilder.build(); + */ + subtract(): GlideDBFunctionBuilder; +} diff --git a/types/servicenow-london/GlideDate.d.ts b/types/servicenow-london/GlideDate.d.ts new file mode 100644 index 0000000000..828128657d --- /dev/null +++ b/types/servicenow-london/GlideDate.d.ts @@ -0,0 +1,154 @@ +/** + * The scoped GlideDate class provides methods for performing operations on GlideDate + * objects, such as instantiating GlideDate objects or working with GlideDate fields. + */ +declare class GlideDate { + /** + * Creates a GlideDate object with the current date time. + */ + constructor(); + + /** + * Gets the date in the specified date format. + * + * @param format the desired date format + * @returns the date in the specified format + * @example + * + * var gd = new GlideDate(); + * gd.setValue('2015-01-01'); + * gs.info(gd.getByFormat('dd-MM-yyyy')); + * // 01-01-2015 + */ + getByFormat(format: string): string; + + /** + * Gets the day of the month stored by the GlideDate object, expressed in the UTC time + * zone. + * + * @returns The day of the month in the UTC time zone, from 1 to 31. + * @example + * + * // Today's date is 2016-05-13 + * var gd = new GlideDate('2016-05-13'); + * gs.info(gd.getDayOfMonthNoTZ()); + * // 13 + */ + getDayOfMonthNoTZ(): number; + + /** + * Gets the date in the current user's display format and time zone. + * + * @returns The date in the user's format and time zone. Keep in mind when designing + * business rules or script includes that this method may return values in different + * formats for different users. + * @example + * + * var gd = new GlideDate(); + * gd.setValue('2015-01-01'); + * gs.info(gd.getDisplayValue()); + * // 2015-01-01 + */ + + getDisplayValue(): string; + + /** + * Gets the display value in the internal format (yyyy-MM-dd). + * + * @returns The date values for the GlideDate object in the current user's time zone and + * the internal time format of yyyy-MM-dd. + * @example + * + * var gd = new GlideDate(); + * gs.info(gd.getDisplayValueInternal()); + * // 2014-10-22 + */ + getDisplayValueInternal(): string; + + /** + * Gets the month stored by the GlideDate object, expressed in the UTC time zone. + * @returns The numerical value of the month from 1 to 12. + * + * @example + * + * // Today's date is 2016-05-13 + * var gd = new GlideDate(); + * gs.info(gd.getMonthNoTZ()); + * // 5 + */ + getMonthNoTZ(): number; + + /** + * Gets the date value stored in the database by the GlideDate object in the internal + * format, yyyy-MM-dd, and the system time zone, UTC by default. + * + * @returns The date value in the internal format and system time zone. + * @example + * + * var gd = new GlideDate(); + * gd.setValue('2015-01-01'); + * gs.info(gd.getValue()); + * // 2015-01-01 + */ + getValue(): string; + + /** + * Gets the year stored by the GlideDate object, expressed in the UTC time zone. + * + * @returns The numerical value of the year. + * @example + * + * // Today's date is 2016-05-13 + * var gd = new GlideDate(); + * gs.info(gd.getYearNoTZ()); + * // 5 + */ + getYearNoTZ(): number; + + /** + * Sets a date value using the current user's display format and time zone. + * + * @param asDisplayed The date in the current user's display format and time zone. The parameter must + * be formatted using the current user's preferred display format, such as yyyy-MM-dd. + * @returns Method does not return a value + * @example + * + * var gd = new GlideDate(); + * gd.setDisplayValue('2011-01-01'); + * gs.info(gd.getValue()); + * // 2011-01-01 + */ + setDisplayValue(asDisplayed: string): void; + + /** + * Sets the date of the GlideDate object. + * + * @param o The date and time to use. + * @returns Method does not return a value + * @example + * + * var gd = new GlideDate(); + * gd.setValue('2015-01-01'); + * gs.info(gd.getValue()); + * // 2015-01-01 + */ + setValue(o: string): void; + + /** + * Gets the duration difference between two GlideDate values. + * + * @param start The start value. + * @param end The end value. + * @returns The duration between the two values. + * @example + * + * var sgd1 = new GlideDate(); + * sgd1.setDisplayValue('2014-07-18'); + * var sgd2 = new GlideDate(); + * sgd2.setDisplayValue('2014-07-19'); + * var duration = GlideDate.subtract(sgd1, sgd2); + * gs.info(duration.getDisplayValue()); + * // 1 Day + */ + static subtract(start: GlideDate | GlideTime, end: GlideDate | GlideTime): GlideDuration; +} diff --git a/types/servicenow-london/GlideDateTime.d.ts b/types/servicenow-london/GlideDateTime.d.ts new file mode 100644 index 0000000000..ad4ef1210b --- /dev/null +++ b/types/servicenow-london/GlideDateTime.d.ts @@ -0,0 +1,833 @@ +/** + * The scoped GlideDateTime class provides methods for performing operations on GlideDateTime + * objects, such as instantiating GlideDateTime objects or working with glide_date_time fields. + */ +declare class GlideDateTime { + /** + * Instantiates a new GlideDateTime object with the current date and time in Greenwich Mean Time + * (GMT). + */ + constructor(); + + /** + * Instantiates a new GlideDateTime object with the current date and time in Greenwich Mean Time + * (GMT). + * + * @param value A UTC date and time using the internal format yyyy-MM-dd HH:mm:ss. + */ + constructor(value: string); + + /** + * Instantiates a new GlideDateTime object with the current date and time in Greenwich Mean Time + * (GMT). + * + * @param g The GlideDateTime object to use for setting the time of the new object. + */ + constructor(g: GlideDateTime); + + /** + * Adds a GlideTime object to the current GlideDateTime object. + * + * @param gd The GlideTime object to add. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * var gtime1 = new GlideTime(); + * gtime1.setValue('00:00:20'); + * gdt.add(gtime1); + * var gtime2 = gdt.getTime(); + * gs.info(gtime2.getByFormat('hh:mm:ss')); + */ + add(gd: GlideTime): void; + + /** + * Adds the specified number of milliseconds to the current GlideDateTime object. + * + * @param milliseconds The number of milliseconds to add. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.getNumericValue()); + * gdt.add(10); + * gs.info(gdt.getNumericValue()); + */ + add(milliseconds: number): void; + + /** + * Adds a specified number of days to the current GlideDateTime object. A negative parameter + * subtracts days. The method determines the local date and time equivalent to the value stored by + * the GlideDateTime object, then adds or subtracts days using the local date and time values. + * + * @param days The number of days to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addDaysLocalTime(-1); + * gs.info(gdt.getLocalDate()); + */ + addDaysLocalTime(days: number): void; + + /** + * Adds a specified number of days to the current GlideDateTime object. A negative parameter + * subtracts days. The method determines the UTC date and time equivalent to the value stored by + * the GlideDateTime object, then adds or subtracts days using the UTC date and time values. + * + * @param days The number of days to add. Use a negative number to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addDaysUTC(-1); + * gs.info(gdt.getDate()); + */ + addDaysUTC(amount: number): void; + + /** + * Adds a specified number of months to the current GlideDateTime object. A negative parameter + * subtracts months. The method determines the local date and time equivalent to the value stored + * by the GlideDateTime object, then adds or subtracts months using the local date and time + * values. + * + * @param months The number of months to add. use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addMonthsLocalTime(2); + * gs.info(gdt.getDate()); + */ + addMonthsLocalTime(amount: number): void; + + /** + * Adds a specified number of months to the current GlideDateTime object. A negative parameter + * subtracts months. The method determines the UTC date and time equivalent to the value stored by + * the GlideDateTime object, then adds or subtracts months using the UTC date and time values. + * + * @param months The number of months to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addMonthsUTC(2); + * gs.info(gdt.getDate()); + */ + addMonthsUTC(amount: number): void; + + /** + * Adds the specified number of seconds to the current GlideDateTime object. + * + * @param seconds The number of seconds to add. + * @example + * + * var gdt = new GlideDateTime('2011-12-07 08:00:00'); + * gdt.addSeconds(1000); + * gs.info(gdt.getValue()); + */ + addSeconds(value: number): void; + + /** + * Adds a specified number of weeks to the current GlideDateTime object. A negative parameter + * subtracts weeks. The method determines the local date and time equivalent to the value stored + * by the GlideDateTime object, then adds or subtracts weeks using the local date and time values. + * + * @param weeks The number of weeks to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addWeeksLocalTime(-1); + * gs.info(gdt.getDate()); + */ + addWeeksLocalTime(amount: number): void; + + /** + * Adds a specified number of weeks to the current GlideDateTime object. A negative parameter + * subtracts weeks. The method determines the UTC date and time equivalent to the value stored by + * the GlideDateTime object, then adds or subtracts weeks using the UTC date and time values. + * + * @param weeks The number of weeks to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addWeeksUTC(-1); + * gs.info(gdt.getDate()); + */ + addWeeksUTC(amount: number): void; + + /** + * Adds a specified number of years to the current GlideDateTime object. A negative parameter + * subtracts years. The method determines the local date and time equivalent to the value stored + * by the GlideDateTime object, then adds or subtracts years using the local date and time values. + * + * @param years The number of years to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addYearsLocalTime(1); + * gs.info(gdt.getDate()); + */ + addYearsLocalTime(amount: number): void; + + /** + * Adds a specified number of years to the current GlideDateTime object. A negative parameter + * subtracts years. The date and time value stored by GlideDateTime object is interpreted as being + * in the UTC time zone. + * + * @param years The number of years to add. Use a negative value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gdt.addYearsUTC(1); + * gs.info(gdt.getDate()); + */ + addYearsUTC(amount: number): void; + + /** + * Determines if the GlideDateTime object occurs after the specified GlideDateTime. + * + * @param gdt The time to check against. + * @returns Returns true if the GlideDateTime object's time is after the time specified by + * the parameter. + * @example + * + * var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + * var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + * gs.info(gdt1.after(gdt2)); + */ + after(gdt: GlideDateTime): boolean; + + /** + * Determines if the GlideDateTime object occurs before the specified GlideDateTime. + * + * @param gdt The time to check against. + * @returns Returns true if the GlideDateTime object's time is before the time specified by + * the parameter. + * @example + * + * var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + * var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + * gs.info(gdt1.before(gdt2)); + */ + + before(gdt: GlideDateTime): boolean; + + /** + * Compares two date and time objects to determine whether they are equivalent or one occurs + * before or after the other. + * + * @param o Date and time object in GlideDateTime format + * @returns + * 0 = Dates are equal + * 1 = The object's date is after the date specified in the parameter + * -1 = The object's date is before the date specified in the parameter + * + * @example + * + * var initDate = new GlideDateTime('2011-08-01 12:00:00'); + * var compDate1 = new GlideDateTime('2011-08-01 12:00:00'); + * var compDate2 = new GlideDateTime('2011-07-31 12:00:00'); + * var compDate3 = new GlideDateTime('2011-08-04 16:00:00'); + * gs.info(initDate.compareTo(compDate1)); // Equals (0) + * gs.info(initDate.compareTo(compDate2)); // initDate is after compDate2 (1) + * gs.info(initDate.compareTo(compDate3)); // initDate is before compDate3 (-1) + */ + compareTo(o: object): number; + + /** + * Compares a datetime with an existing value for equality. + * + * @param dateTime The datetime to compare. + * @returns Returns true if they are equal; otherwise, false. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 00:00:00'); + * gs.info(gdt.equals('2011-09-30 00:12:01')); + */ + equals(dateTime: GlideDateTime | string): boolean; + + /** + * Gets the date stored by the GlideDateTime object, expressed in the standard format, yyyy-MM-dd, + * and the system time zone, UTC by default. + * + * @returns The date in the system time zone. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 00:00:00'); + * gs.info(gdt.getDate()); + */ + getDate(): GlideTime; + + /** + * Gets the day of the month stored by the GlideDateTime object, expressed in the current user's + * time zone. + * + * @returns The day of the month in the user's time zone, from 1 to 31. + * @example + * + * var gdt = new GlideDateTime('2011-12-02 12:00:00'); + * gs.info(gdt.getDayOfMonthLocalTime()); + */ + getDayOfMonthLocalTime(): number; + + /** + * Gets the day of the month stored by the GlideDateTime object, expressed in the UTC time zone. + * + * @returns The day of the month in the UTC time zone, from 1 to 31. + * @example + * + * var gdt = new GlideDateTime('2011-12-02 12:00:00'); + * gs.info(gdt.getDayOfMonthUTC()); + */ + getDayOfMonthUTC(): number; + + /** + * Gets the day of the week stored by the GlideDateTime object, expressed in the user's time zone. + * + * @returns The day of week value, in the user's time zone, from 1 to 7. Monday equals 1, Sunday + * equals 7. + * @example + * + * var gdt = new GlideDateTime('2011-12-01 12:00:00');//Thursday + * gs.info(gdt.getDayOfWeekLocalTime()); + */ + getDayOfWeekLocalTime(): number; + + /** + * Gets the day of the week stored by the GlideDateTime object, expressed in the UTC time zone. + * + * @returns The day of week value from 1 to 7. Monday equals 1, Sunday equals 7. + * @example + * + * var gdt = new GlideDateTime('2011-12-01 12:00:00');//Thursday + * gs.info(gdt.getDayOfWeekLocalTime()); + */ + getDayOfWeekUTC(): number; + + /** + * Gets the number of days in the month stored by the GlideDateTime object, expressed in the + * current user's time zone. + * + * @returns The number of days in the current month in the user's time zone. + * @example + * + * var gdt = new GlideDateTime('2011-12-02 12:00:00'); //December + * gs.info(gdt.getDaysInMonthLocalTime()); + */ + getDaysInMonthLocalTime(): number; + + /** + * Gets the number of days in the month stored by the GlideDateTime object, expressed in the UTC + * time zone. + * + * @returns The number of days in the month stored by the GlideDateTime object, expressed in the + * UTC time zone. + * @example + * + * var gdt = new GlideDateTime('2011-11-02 12:00:00'); //November + * gs.info(gdt.getDaysInMonthUTC()); + */ + getDaysInMonthUTC(): number; + + /** + * Gets the date and time value in the current user's display format and time zone. + * + * @returns The date and time in the user's format and time zone. Keep in mind when designing + * business rules or script includes that this method may return values in different formats for + * different users. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.getDisplayValue()); //uses current user session time zone (US/Pacific) + */ + getDisplayValue(): string; + + /** + * Gets the display value in the internal format (yyyy-MM-dd HH:mm:ss). + * + * @returns The date and time values for the GlideDateTime object in the current user's time zone + * and the internal date and time format of yyyy-MM-dd HH:mm:ss. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.getDisplayValueInternal()); //uses current user session time zone (US/Pacific) + */ + getDisplayValueInternal(): string; + + /** + * Gets the amount of time that daylight saving time is offset. + * + * @returns Amount of time, in milliseconds, that daylight saving is offset. Returns 0 if there is + * no offset or if the time is not during daylight saving time. + * @example + * + * var gdt = new GlideDateTime('2014-08-31 08:00:00'); + * gs.info(gdt.getDSTOffset()); //uses current user session time zone (US/Pacific) + */ + getDSTOffset(): number; + + /** + * Gets the current error message. + * + * @returns The error message. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setDisplayValue('2011-aa-01 00:00:00'); + * gs.info(gdt.getErrorMsg()); + */ + getErrorMsg(): string; + + /** + * Returns the object's time in the local time zone and in the internal format. + * + * @returns The object's time in the local time zone and the internal format. + */ + getInternalFormattedLocalTime(): string; + + /** + * Gets the date stored by the GlideDateTime object, expressed in the standard format, yyyy-MM-dd, + * and the current user's time zone. + * + * @returns The date in the user's time zone. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.getLocalDate()); + */ + getLocalDate(): GlideTime; + + /** + * Returns a GlideTime object that represents the time portion of the GlideDateTime object in the + * user's time zone. + * + * @returns The time in the user's time zone. + * @example + * + * var gdt = new GlideDateTime('2014-08-31 08:00:00'); + * gt = gdt.getLocalTime(); + * gs.info("local time is " + gt.getByFormat('hh:mm:ss')); + */ + getLocalTime(): GlideTime; + + /** + * Gets the month stored by the GlideDateTime object, expressed in the current user's time zone. + * + * @returns The numerical value of the month. + * @example + * + * var gdt = new GlideDateTime('2011-11-02 12:00:00'); //November + * gs.info(gdt.getMonthLocalTime()); + */ + getMonthLocalTime(): number; + + /** + * Gets the month stored by the GlideDateTime object, expressed in the UTC time zone. + * + * @returns The numerical value of the month. + * @example + * + * var gdt = new GlideDateTime('2011-11-02 12:00:00'); //November + * gs.info(gdt.getMonthUTC()); + */ + getMonthUTC(): number; + + /** + * Gets the number of milliseconds since January 1, 1970, 00:00:00 GMT. + * + * @returns The number of milliseconds since January 1, 1970, 00:00:00 GMT. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.getNumericValue()); + */ + getNumericValue(): number; + + /** + * Returns a GlideTime object that represents the time portion of the GlideDateTime object. + * + * @returns The Unix duration stamp in system format based on GMT time. + * @example + * + * var gdt = new GlideDateTime('2014-08-31 08:00:00'); + * gt = gdt.getTime(); + * gs.info(gt.getByFormat('hh:mm:ss')); + */ + getTime(): GlideTime; + + /** + * Gets the time zone offset in milliseconds. + * + * @returns The number of milliseconds of time zone offset. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.getLocalTime(); // PST local time + * gs.info(gdt.getTZOffset()); + */ + getTZOffset(): number; + + /** + * Returns the object's time in the local time zone and in the user's format. + * + * @returns The object's time in the local time zone and in the user's format. + */ + getUserFormattedLocalTime(): string; + + /** + * Gets the date and time value stored by the GlideDateTime object in the internal format, + * yyyy-MM-dd HH:mm:ss, and the system time zone, UTC by default. + * + * @returns The date and time value in the internal format and system time zone. + * @example + * + * var gdt = new GlideDateTime('2014-08-31 08:00:00'); + * gs.info(gdt.getValue()); + */ + getValue(): string; + + /** + * Gets the number of the week stored by the GlideDateTime object, expressed in the current user's + * time zone. All weeks begin on Sunday. The first week of the year is the week that contains at + * least one day of the new year. The week beginning Sunday 2015-12-27 is considered the first + * week of 2016 as that week contains January 1 and 2. + * + * @returns The number of the current week in local time. The highest week number in a year is + * either 52 or 53. + * @example + * + * var gdt = new GlideDateTime('2011-12-01 12:00:00');//49th week, 1st week in december + * gs.info(gdt.getWeekOfYearLocalTime()); + */ + getWeekOfYearLocalTime(): number; + + /** + * Gets the number of the week stored by the GlideDateTime object, expressed in the UTC time zone. + * All weeks begin on Sunday. The first week of the year is the week that contains at least one + * day of the new year. The week beginning Sunday 2015-12-27 is considered the first week of 2016 + * as that week contains January 1 and 2. + * + * @returns The number of the current week in UTC time. The highest week number in a year is + * either 52 or 53. + * @example + * + * var gdt = new GlideDateTime('2011-12-01 12:00:00');//49th week, 1st week in december + * gs.info(gdt.getWeekOfYearUTC()); + */ + getWeekOfYearUTC(): number; + + /** + * Gets the year stored by the GlideDateTime object, expressed in the current user's time zone. + * + * @returns Four-digit year value in the user's time zone. + * @example + * + * var gdt = new GlideDateTime('2011-11-02 12:00:00'); + * gs.info(gdt.getYearLocalTime()); + */ + getYearLocalTime(): number; + + /** + * Gets the year stored by the GlideDateTime object, expressed in the UTC time zone. + * + * @returns 4-digit year value in the UTC time zone. + * @example + * + * var gdt = new GlideDateTime('2011-11-02 12:00:00'); + * gs.info(gdt.getYearUTC()); + */ + getYearUTC(): number; + + /** + * Determines if an object's date is set. + * + * @returns True if the object date is set; otherwise, returns false. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.hasDate()); + */ + hasDate(): boolean; + + /** + * Determines if an object's time uses a daylight saving offset. + * + * @returns True if the time is daylight saving; otherwise, returns false. + * @example + * + * var gdt = new GlideDateTime('2014-08-31 00:00:00'); + * gs.info(gdt.isDST()); //true + */ + isDST(): boolean; + + /** + * Determines if a value is a valid date and time. + * + * @returns True if value is valid; otherwise, returns false. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setDisplayValue('2011-aa-01 00:00:00'); + * gs.info(gdt.isValid()); + */ + isValid(): boolean; + + /** + * Determines if the GlideDateTime object occurs on or after the specified GlideDateTime. + * + * @param gdt The time to check against. + * @returns Returns true if the GlideDateTime object's time is on or after the time specified by + * the parameter. + * @example + * + * var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + * var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + * gs.info(gdt1.onOrAfter(gdt2)); + */ + onOrAfter(gdt: GlideDateTime): boolean; + + /** + * Determines if the GlideDateTime object occurs on or before the specified GlideDateTime. + * + * @param gdt The time to check against. + * @returns Returns true if the GlideDateTime object's time is on or before the time specified by + * the parameter. + * @example + * + * var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + * var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + * gs.info(gdt1.onOrBefore(gdt2)); + */ + onOrBefore(gdt: GlideDateTime): boolean; + + /** + * Sets the day of the month to a specified value in the current user's time zone. + * + * @param day The day of month to change to, from 1 to 31. If this value is greater than the + * maximum number of days in the month, the value is set to the last day of the month. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setDayOfMonthLocalTime(9); + * gs.info(gdt.getDayOfMonthLocalTime()); + */ + setDayOfMonthLocalTime(day: number): void; + + /** + * Sets the day of the month to a specified value in the UTC time zone. + * + * @param day The day of month to change to, from 1 to 31. If this value is greater than the + * maximum number of days in the month, the value is set to the last day of the month. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setDayOfMonthUTC(9); + * gs.info(gdt.getDayOfMonthUTC()); + */ + setDayOfMonthUTC(day: number): void; + + /** + * Sets a date and time value using the current user's display format and time zone. + * + * @param asDisplayed The date and time in the current user's display format and time zone. The + * parameter must be formatted using the current user's preferred display format, such as + * MM-dd-yyyy HH:mm:ss. To assign the current date and time to a variable in a workflow script, + * use variable.setDisplayValue(gs.nowDateTime);. + * @example + * + * var gdt = new GlideDateTime('2014-02-02 12:00:00'); + * gdt.setDisplayValue('2014-01-01 12:00:00');//uses current user session time zone (US/Pacific) + * gs.info(gdt.getValue()); + */ + setDisplayValue(asDisplayed: string): void; + + /** + * Sets a date and time value using the current user's time zone and the specified date and time + * format. This method throws a runtime exception if the date and time format used in the value + * parameter does not match the format parameter. + * + * You can retrieve the error message by calling getErrorMsg() on the GlideDateTime object after + * the exception is caught. + * + * @param value The date and time in the current user's time zone. + * @param format The date and time format to use to parse the value + * parameter. + * @example + * + * var gdt = new GlideDateTime('2011-02-02 12:00:00'); + * gdt.setDisplayValue('20-5-2011 12:00:00', 'dd-MM-yyyy HH:mm:ss'); //uses current user session time zone (US/Pacific) + * gs.info(gdt.getValue()); + */ + setDisplayValue(value: string, format?: string): void; + + /** + * Sets a date and time value using the internal format (yyyy-MM-dd HH:mm:ss) and the current + * user's time zone. + * + * @param value The date and time in internal format. + * @example + * + * var gdt = new GlideDateTime('2014-02-02 12:00:00'); + * //uses current user session time zone (US/Pacific) + * gdt.setDisplayValueInternal('2014-01-01 12:00:00'); + * gs.info(gdt.getValue()); + */ + setDisplayValueInternal(value: string): void; + + /** + * Sets the date and time of the current object using an existing GlideDateTime object. This + * method is equivalent to instantiating a new object with a GlideDateTime parameter. + * + * @param g The object to use for setting the datetime value. + * @example + * + * var dt1 = new GlideDateTime('2011-01-01 12:00:00'); + * var dt2 = new GlideDateTime('2011-02-02 08:00:00'); + * dt1.setGlideDateTime(dt2); + * gs.info(dt1.getValue()); + */ + setGlideDateTime(g: GlideDateTime): void; + + /** + * Sets the month stored by the GlideDateTime object to the specified value using the current + * user's time zone. + * + * @param month The month to change to. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setMonthLocalTime(1); + * gs.info(gdt.getMonthLocalTime()); + */ + setMonthLocalTime(month: number): void; + + /** + * Sets the month stored by the GlideDateTime object to the specified value using the UTC time + * zone. + * + * @param month The month to change to. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setMonthUTC(1); + * gs.info(gdt.getMonthUTC()); + */ + setMonthUTC(month: number): void; + + /** + * Sets the date and time of the GlideDateTime object. + * + * @param o The date and time to use. This parameter may be one of several types: + * + * - A string in the UTC time zone and the internal format of yyyy-MM-dd HH:mm:ss. Sets the value + * of the object to the specified date and time. Using the method this way is equivalent to + * instantiating a new GlideDateTime object using the GlideDateTime(String value) constructor. If + * the date and time format used does not match the internal format, the method attempts to set + * the date and time using other available formats. Resolving the date and time this way can lead + * to inaccurate data due to ambiguity in the day and month values. When using a non-standard date + * and time format, use setValueUTC(String dt, String format) instead. + * - A GlideDateTime object. Sets the value of the object to the date and time stored by the + * GlideDateTime passed in the parameter. Using the method this way is equivalent to instantiating + * a new GlideDateTime object using the GlideDateTime(GlideDateTime g) constructor. + * - A JavaScript Number. Sets the value of the object using the Number value as milliseconds past + * January 1, 1970 00:00:00 GMT. + * @example + * + * var gdt = new GlideDateTime('2011-01-01 12:00:00'); + * gdt.setValue('2011-02-02 08:00:00'); // value set = 2011-02-02 08:00:00 + * gs.info(gdt.getValue()); + */ + setValue(o: string | number | GlideDateTime): void; + + /** + * Sets a date and time value using the UTC time zone and the specified date and time format. This + * method throws a runtime exception if the date and time format used in the `dt` parameter does + * not match the `format` parameter. You can retrieve the error message by calling `getErrorMsg()` + * on the GlideDateTime object after the exception is caught. + * + * @param dt The date and time to use. + * @param format The date and time format to use. + * @example + * + * var gdt = new GlideDateTime('2011-01-01 12:00:00'); + * gdt.setValueUTC('15-02-2011 08:00:00', 'dd-MM-yyyy HH:mm:ss'); + * gs.info(gdt.getValue()); + */ + setValueUTC(dt: string, format: string): void; + + /** + * Sets the year stored by the GlideDateTime object to the specified value using the current + * user's time zone. + * + * @param year The year to change to. + * @example var gdt = new GlideDateTime(); + * gdt.setYearLocalTime(2013); + * gs.info(gdt.getYearLocalTime()); + */ + setYearLocalTime(year: number): void; + + /** + * Sets the year stored by the GlideDateTime object to the specified value using the UTC time + * zone. + * + * @param year The year to change to. + * @example + * + * var gdt = new GlideDateTime(); + * gdt.setYearUTC(2013); + * gs.info(gdt.getYearUTC()); + */ + setYearUTC(year: number): void; + + /** + * Gets the duration difference between two GlideDateTime values. + * + * @param Start The start value. + * @param End The end value. + * @returns The duration between the two values. + * @example + * + * var gdt1 = new GlideDateTime('2011-08-28 09:00:00'); + * var gdt2 = new GlideDateTime('2011-08-31 08:00:00'); + * var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2 + * gs.info(dur.getDisplayValue()); + */ + static subtract(start: GlideDateTime, end?: GlideDateTime): GlideDuration; + + /** + * Subtracts a specified amount of time from the current GlideDateTime object. + * + * @param time The time value to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * var gtime1 = new GlideTime(); + * gtime1.setValue('00:00:20'); + * gdt.subtract(gtime1); + * var gtime2 = gdt.getTime(); + * gs.info(gtime2.getByFormat('hh:mm:ss')); + */ + + subtract(time: GlideTime): void; + + /** + * Subtracts the specified number of milliseconds from the GlideDateTime object. + * + * @param milliseconds The number of milliseconds to subtract. + * @example + * + * var gdt = new GlideDateTime('2011-12-07 08:00:00'); + * gdt.subtract(1000); + * gs.info(gdt.getValue()); + */ + subtract(milliseconds: number): void; + + /** + * Gets the date and time value stored by the GlideDateTime object in the internal format, + * yyyy-MM-dd HH:mm:ss, and the system time zone, UTC by default. This method is equivalent to + * getValue(). + * + * @returns The date and time stored by the GlideDateTime object in the system time zone + * and format. + * @example + * + * var gdt = new GlideDateTime('2011-08-31 08:00:00'); + * gs.info(gdt.toString()); + */ + toString(): string; +} diff --git a/types/servicenow-london/GlideDuration.d.ts b/types/servicenow-london/GlideDuration.d.ts new file mode 100644 index 0000000000..b616be5000 --- /dev/null +++ b/types/servicenow-london/GlideDuration.d.ts @@ -0,0 +1,160 @@ +/** + * The scoped GlideDuration class provides methods for working with spans of time or durations. + * + * GlideDuration objects store the duration as a date and time from January 1, 1970, 00:00:00. + * As a result, setValue() and getValue() use the scoped GlideDateTime object for parameters and + * return values. + */ +declare class GlideDuration { + /** + * Instantiates a GlideDuration object. + */ + constructor(); + + /** + * Instantiates a GlideDuration object by cloning the value of another GlideDuration object. + * + * @param another Another scoped GlideDuration object. + */ + constructor(another: GlideDuration); + + /** + * Instantiates a GlideDuration object with the specified duration. + * + * @param milliseconds The duration value in milliseconds. + */ + constructor(milliseconds: number); + + /** + * Instantiates a GlideDuration object with the specified display value. + * + * @param displayValue The display value. + */ + constructor(displayValue: string); + + /** + * Add the specified duration to the object. + * + * @param duration The value to add to the object. + * @returns The sum of the current and the added duration. + * @example + * + * var duration = new GlideDuration('3 12:00:00'); + * var duration2 = new GlideDuration('3:00:00'); + * var answer = duration.add(duration2); + * gs.info(answer.getDisplayValue()); + */ + add(value: GlideDuration): GlideDuration; + + /** + * Gets the duration in the specified format. + * + * @param format The duration format. + * @returns The current duration in the specified format. + * @example + * + * var dur = new GlideDuration('3 22:00:00'); + * gs.info(dur.getByFormat('HH:mm')); + */ + getByFormat(format: string): string; + + /** + * Gets the number of days. + * + * @returns The number of days. + * @example + * + * var dur = new GlideDuration('3 12:00:00'); + * gs.info(dur.getDayPart()); + */ + getDayPart(): number; + + /** + * Gets the display value of the duration in number of days, hours, and + * minutes. + * + * @returns The number of days, hours, and minutes. + * @example + * + * var dur = new GlideDuration('3 12:00:00'); + * gs.info(dur.getDisplayValue()); + */ + getDisplayValue(): string; + + /** + * Gets the duration value in "d HH:mm:ss" format. + * + * @returns The duration value. + * @example + * + * var dur = new GlideDuration('3 12:00:00'); + * gs.info(dur.getDurationValue()); + */ + getDurationValue(): string; + + /** + * Gets the rounded number of days. If the time part is more than 12 hours, the return value is + * rounded up. Otherwise, it is rounded down. + * + * @returns The day part, rounded. + * @example + * + * var dur = new GlideDuration('3 11:00:00'); + * gs.info(dur.getRoundedDayPart()); + */ + getRoundedDayPart(): number; + + /** + * Gets the internal value of the GlideDuration object. + * + * @returns The duration in the object's internal format, which is the date and time from + * January 1, 1970, 00:00:00. + * @example + * + * var dur = new GlideDuration('3 12:00:00'); + * gs.info(dur.getValue()); + */ + getValue(): string; + + /** + * Sets the display value. + * + * @param asDisplayed The duration in "d HH:mm:ss" format. + * @returns Method does not return a value + * @example + * + * var dur = new GlideDuration(); + * dur.setDisplayValue('3 08:00:00'); + * gs.info(dur.getDisplayValue()); + */ + + setDisplayValue(asDisplayed: string): void; + + /** + * Sets the internal value of the GlideDuration object. + * + * @param value The duration in the object's internal format, which is the date and time from + * January 1, 1970, 00:00:00. + * @example + * + * var dur = new GlideDuration(); + * // Sets internal DateTime value. The String will be parsed into a GlideDateTime object. + * dur.setValue('1970-01-05 08:00:00'); + * gs.info(dur.getDisplayValue()); + */ + setValue(value: string): void; + + /** + * Subtracts the specified duration from the current duration. + * + * @param duration The duration to subtract. + * @returns GlideDuration of the difference. + * @example + * + * var duration = new GlideDuration('3 12:00:00'); + * var duration2 = new GlideDuration('3:00:00'); + * var answer = duration.subtract(duration2); + * gs.info(answer.getDisplayValue()); + */ + subtract(value: GlideDuration): GlideDuration; +} diff --git a/types/servicenow-london/GlideEmailOutbound.d.ts b/types/servicenow-london/GlideEmailOutbound.d.ts new file mode 100644 index 0000000000..c9589efb71 --- /dev/null +++ b/types/servicenow-london/GlideEmailOutbound.d.ts @@ -0,0 +1,90 @@ +/** + * The scoped GlideEmailOutbound class implements the email object for scoped applications. + * You can use the GlideEmailOutbound methods with the email global object available in mail + * scripts. The email object behaves identically for global and scoped applications. + */ +declare class GlideEmailOutbound { + /** + * Instantiates a scoped GlideEmailOutbound object. + */ + constructor(); + + /** + * Adds the address to either the cc or bcc list. + * + * @param type Either cc or bcc, determines the list to which the address is added. + * @param address The recipient's email address. + * @example + * + * email.addAddress('cc', 'joe.employee@something.com'); + */ + addAddress(type: string, address: string): void; + + /** + * Adds the recipient to either the cc or bcc list, but uses the display name instead of the + * address when showing the recipient. + * + * @param type Either cc or bcc, determines the list to which the address is added. + * @param address The recipient's email address. + * @param displayName The name to be shown instead of the email address. + * @example + * + * email.addAddress('bcc', 'joe.employee@something.com', 'dudley rocks'); + */ + addAddress(type: string, address: string, displayName: string): void; + + /** + * Returns the email's subject line. + * + * @returns The email's subject line. + * @example + * + * var subject = email.getSubject(); + */ + getSubject(): string; + + /** + * Returns the email's watermark. + */ + getWatermark(): string; + + /** + * Sets the body of the email. + * + * @param bodyText The body of the email. + * @example + * + * email.setBody('Dear Sir, ...'); + */ + setBody(bodyText: string): void; + + /** + * Sets the sender's address. + * + * @param address The sender's email address. + * @example + * + * email.setFrom('joe.employee@something.com'); + */ + setFrom(address: string): void; + + /** + * Sets the reply to address. + * + * @param address The reply to email address. + * @example + * + * email.setReplyTo('joe.employee@something.com'); + */ + setReplyTo(address: string): void; + + /** + * Sets the email's subject line. + * + * @param subject Text for the subject line. + * @example + * + * email.setSubject('Important Issues to discuss'); + */ + setSubject(subject: string): void; +} diff --git a/types/servicenow-london/GlideFilter.d.ts b/types/servicenow-london/GlideFilter.d.ts new file mode 100644 index 0000000000..31694e19b7 --- /dev/null +++ b/types/servicenow-london/GlideFilter.d.ts @@ -0,0 +1,3 @@ +declare const GlideFilter: { + checkRecord(gr: ScopedGlideRecord, filter: string, matchAll?: object): boolean; +}; diff --git a/types/servicenow-london/GlideLocale.d.ts b/types/servicenow-london/GlideLocale.d.ts new file mode 100644 index 0000000000..841d3d47a2 --- /dev/null +++ b/types/servicenow-london/GlideLocale.d.ts @@ -0,0 +1,5 @@ +declare class GlideLocale { + static get(): GlideLocale; + getGroupingSeparator(): string; + getDecimalSeparator(): string; +} diff --git a/types/servicenow-london/GlidePluginManager.d.ts b/types/servicenow-london/GlidePluginManager.d.ts new file mode 100644 index 0000000000..f60dfe1433 --- /dev/null +++ b/types/servicenow-london/GlidePluginManager.d.ts @@ -0,0 +1,3 @@ +declare class GlidePluginManager { + isActive(pluginId: string): boolean; +} diff --git a/types/servicenow-london/GlideRecordOperation.d.ts b/types/servicenow-london/GlideRecordOperation.d.ts new file mode 100644 index 0000000000..06ad6eb255 --- /dev/null +++ b/types/servicenow-london/GlideRecordOperation.d.ts @@ -0,0 +1 @@ +type GlideRecordOperation = 'insert' | 'update' | 'delete'; diff --git a/types/servicenow-london/GlideSchedule.d.ts b/types/servicenow-london/GlideSchedule.d.ts new file mode 100644 index 0000000000..435b7c8506 --- /dev/null +++ b/types/servicenow-london/GlideSchedule.d.ts @@ -0,0 +1,167 @@ +/** + * 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. + */ +declare class GlideSchedule { + /** + * Instantiates an empty GlideSchedule object. + */ + constructor(); + + /** + * Instantiates a GlideSchedule object and loads the schedule information. If a timezone is not + * specified or is nil, the current session timezone is used. + * + * @param sysId The system ID for the schedule. + * @param timeZone The time zone. (Optional) + * @example + * + * var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', 'US/Pacific'); + */ + constructor(sysId: string, timeZone?: string); + + /** + * Adds a new schedule segment to the current schedule. + * + * @param startDate The starting date of the new schedule segment. + * @param offSet The time offset of the new schedule segment. + * @returns The schedule updated with the new schedule segment. + * + * @example + * + * var startDate = new GlideDateTime('2014-01-02'); + * var days = 2; + * var dur = new GlideDuration(60 * 60 * 24 * 1000 * days); + * var schedule = new GlideSchedule(); + * var end = schedule.add(startDate, dur); + * gs.info(end); + */ + add(startDate: GlideDateTime, offset: GlideDuration): GlideDateTime; + + /** + * 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. + * + * @param startDate The starting datetime. + * @param endDate The ending datetime. + * @returns The difference between the starting and ending datetime. + * + * @example + * + * var startDate = new GlideDateTime('2014-10-16 02:00:00'); + * var endDate = new GlideDateTime('2014-10-18 04:00:00'); + * var schedule = new GlideSchedule(); + * // loads "8-5 weekdays excluding holidays" schedule + * schedule.load('090eecae0a0a0b260077e1dfa71da828'); + * var duration = schedule.duration(startDate, endDate); + * gs.info(duration.getDurationValue()); // gets the elapsed time in schedule + */ + duration(startDate: GlideDateTime, endDate: GlideDateTime): GlideDuration; + + /** + * Retrieves the schedule name. + * + * @returns The name of the current schedule. + * + * @example + * + * sys_id ='04e664654a36232701a2247dcd8fc4cf'; // sys_id for "Application" schedule record + * var sched = new GlideSchedule(sys_id); + * gs.info(sched.getName()); + */ + getName(): string; + + /** + * Determines if the given datetime is within the current schedule. + * + * @param time The datetime value to check. + * @returns True if the specified datetime is within the schedule; otherwise, + * false. + * + * @example + * + * var g = new GlideRecord('cmn_schedule'); + * g.addQuery('type', 'blackout'); + * g.query(); + * if (g.next()) { + * var sched = new GlideSchedule(g.sys_id); + * var d = new GlideDateTime(); + * d.setDisplayValue("2007-09-18 12:00:00"); + * if (sched.isInSchedule(d)) + * gs.info("Is in the schedule"); + * else + * gs.info("Is NOT in the schedule"); + * } + */ + isInSchedule(time: GlideDateTime): string; + + /** + * Determines if the current schedule is valid. A schedule is valid if it has at least one + * schedule span. + * + * @returns True if the schedule is valid. + * + * @example + * + * var g = new GlideRecord('cmn_schedule'); + * g.addQuery('type', 'blackout'); + * g.query(); + * if (g.next()) { + * var sched = new GlideSchedule(g.sys_id); + * var d = new GlideDateTime(); + * d.setDisplayValue("2007-09-18 12:00:00"); + * if (sched.isValid()) + * gs.info("Is valid"); + * else + * gs.info("Is not valid"); + * } + */ + isValid(): boolean; + + /** + * Loads a schedule with the schedule information. + * + * @param sysID The system ID of the schedule. + * @param [timeZone] (Optional) The timezone. If a timezone is not specified, or is nil, the + * current session timezone is used for the schedule. + * @param [excludeSpanID] Any span to exclude. + * @returns Method does not return a value + * + * @example + * + * var x = new GlideSchedule(); + * x.load('08fcd0830a0a0b2600079f56b1adb9ae'); + */ + load(sysId: string, timeZone?: string, excludeSpanId?: string): void; + + /** + * Sets the timezone for the current schedule. + * + * @param timeZone The timezone. + * @returns Method does not return a value + * + * @example + * + * var schedule = new GlideSchedule(); + * schedule.setTimeZone('US/Pacific'); + */ + setTimeZone(tz: string): void; + + /** + * Determines how much time (in milliseconds) until start time of the next schedule + * item. + * + * @param time The time to be evaluated. + * @param [timeZone] The timezone. + * @returns The number of milliseconds until the start time of the next schedule item. + * Returns -1 if never. + * + * @example + * + * var startDate = new GlideDateTime('2014-10-25 08:00:00'); + * var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', 'UTC'); + * gs.info(glideSchedule.whenNext(startDate)); + */ + whenNext(time: GlideDateTime, timeZone?: string): number; +} diff --git a/types/servicenow-london/GlideScopedEvaluator.d.ts b/types/servicenow-london/GlideScopedEvaluator.d.ts new file mode 100644 index 0000000000..bb84e99329 --- /dev/null +++ b/types/servicenow-london/GlideScopedEvaluator.d.ts @@ -0,0 +1,95 @@ +/** + * The GlideScopedEvaluator API allows you to evaluate scripts in a GlideRecord field from + * both scoped and global server scripts. + */ +declare class GlideScopedEvaluator { + /** + * Instantiates a GlideScopedEvaluator object. + */ + constructor(); + + /** + * Evaluates a script from a GlideRecord field. + * + * @param grObj The GlideRecord containing a script expression. + * @param [scriptField] (Optional) The name of the field containing the script expression. + * @param [variables] (Optional) A map of variables with name-value pairs. These variables are + * available to the script during execution of this method. + * @returns The result of the script execution. + * @example + * + * // For this example, we created a table: "x_app_table" with two columns: + * // "short_description", "test_script" + * // "test_script" will store the script to be evaluated by GlideScopedEvaluator. + * gr = new GlideRecord('x_app_table'); + * gr.short_description = 'Testing GlideScopedEvaluator'; + * gr.test_script = "gs.getUser().getName() + ' says ' + greeting; "; + * gr.insert(); + * // setup variables to be used by the script + * var vars = {'greeting' : 'hello'}; + * //Evaluate the script from the field + * var evaluator = new GlideScopedEvaluator(); + * gr = new GlideRecord('x_app_table'); + * gr.addQuery('short_description','Testing GlideScopedEvaluator'); + * gr.query(); + * if (gr.next()) { + * gs.info(evaluator.evaluateScript(gr, 'test_script', vars)); + * } + */ + evaluateScript(grObj: ScopedGlideRecord, scriptField?: string, variables?: object | null): any; + + /** + * Returns a variable from a GlideScopedEvaluator object. + * + * @param name The name of the variable. + * @returns The value of the specified variable. + * @example + * + * //setting up a record that contains the script to be executed. + * gr = new GlideRecord('x_app_table'); + * gr.short_description = 'Calculate Addition'; + * gr.calculate = "result = x + y"; + * gr.insert(); + * var evaluator = new GlideScopedEvaluator(); + * evaluator.putVariable('x', 100); + * evaluator.putVariable('y', 200); + * evaluator.putVariable('result', null); + * // Now retrieve the result + * gr = new GlideRecord('x_app_table'); + * gr.addQuery('short_description','Calculate Addition'); + * gr.query(); + * if (gr.next()) { + * evaluator.evaluateScript(gr, 'calculate', null); + * gs.info(evaluator.getVariable('result')); + * } + */ + getVariable(name: string): any; + + /** + * Puts a variable into the GlideScopedEvaluator object. These variables are available to + * the script that this GlideScopedEvaluator object runs. + * + * @param name The name of the variable. + * @param value The value of the variable. + * @example + * + * //setting up a record that contains the script to be executed. + * gr = new GlideRecord('x_app_table'); + * gr.short_description = 'Calculate Addition'; + * gr.calculate = "result = x + y"; + * gr.insert(); + * var evaluator = new GlideScopedEvaluator(); + * evaluator.putVariable('x', 100); + * evaluator.putVariable('y', 200); + * evaluator.putVariable('result', null); + * // Now retrieve the result + * gr = new GlideRecord('x_app_table'); + * gr.addQuery('short_description','Calculate Addition'); + * gr.query(); + * if (gr.next()) { + * evaluator.evaluateScript(gr, 'calculate', null); + * gs.info(evaluator.getVariable('result')); + * } + */ + putVariable(name: string, value: any): void; +} diff --git a/types/servicenow-london/GlideScriptedProcessor.d.ts b/types/servicenow-london/GlideScriptedProcessor.d.ts new file mode 100644 index 0000000000..3ad2a72c97 --- /dev/null +++ b/types/servicenow-london/GlideScriptedProcessor.d.ts @@ -0,0 +1,5 @@ +interface GlideScriptedProcessor { + redirect(url: string): void; + writeOutput(contentType: string, s?: string): void; + writeJSON(o: object): void; +} diff --git a/types/servicenow-london/GlideSecureRandomUtil.d.ts b/types/servicenow-london/GlideSecureRandomUtil.d.ts new file mode 100644 index 0000000000..545354d30a --- /dev/null +++ b/types/servicenow-london/GlideSecureRandomUtil.d.ts @@ -0,0 +1,6 @@ +declare const GlideSecureRandomUtil: { + getSecureRandomInt(): number; + getSecureRandomIntBound(bound: number): number; + getSecureRandomLong(): number; + getSecureRandomString(length: number): string; +}; diff --git a/types/servicenow-london/GlideServletRequest.d.ts b/types/servicenow-london/GlideServletRequest.d.ts new file mode 100644 index 0000000000..027d81413f --- /dev/null +++ b/types/servicenow-london/GlideServletRequest.d.ts @@ -0,0 +1,11 @@ +interface GlideServletRequest { + getContentType(): string; + getHeader(name: string): string; + getHeaderNames(): string; + getHeaders(name: string): string; + getParameter(name: string): string; + getParameterNames(): string; + getQueryString(): string; + writeOutput(mimeType: string, output: string): void; + toString(): string; +} diff --git a/types/servicenow-london/GlideServletResponse.d.ts b/types/servicenow-london/GlideServletResponse.d.ts new file mode 100644 index 0000000000..1e2c4af3ed --- /dev/null +++ b/types/servicenow-london/GlideServletResponse.d.ts @@ -0,0 +1,5 @@ +interface GlideServletResponse { + setContentType(type: string): void; + setHeader(name: string, value: string): void; + setStatus(value: number): void; +} diff --git a/types/servicenow-london/GlideSession.d.ts b/types/servicenow-london/GlideSession.d.ts new file mode 100644 index 0000000000..ccf9a61c5d --- /dev/null +++ b/types/servicenow-london/GlideSession.d.ts @@ -0,0 +1,13 @@ +interface GlideSession { + isInteractive(): boolean; + isLoggedIn(): boolean; + getClientData(paramName: string): string; + getClientIP(): string; + getCurrentApplicationId(): string; + getLanguage(): string; + getTimeZoneName(): string; + getSessionToken(): string; + getUrlOnStack(): string; + isImpersonating(): boolean; + putClientData(paramName: string, paramValue: string): void; +} diff --git a/types/servicenow-london/GlideStringUtil.d.ts b/types/servicenow-london/GlideStringUtil.d.ts new file mode 100644 index 0000000000..326296d12d --- /dev/null +++ b/types/servicenow-london/GlideStringUtil.d.ts @@ -0,0 +1,16 @@ +declare const GlideStringUtil: { + dotToUnderBar(sourceString: string): string; + escapeAllQuotes(sourceString: string): string; + escapeForHomePage(sourceString: string): string; + escapeHTML(htmlString: string): string; + escapeNonPrintable(sourceString: string): string; + escapeQueryTermSeparator(sourceString: string): string; + escapeTicks(sourceString: string): string; + getHTMLValue(sourceString: string): string; + getNumeric(sourceString: string): string; + isBase64(sourceString: string): boolean; + isEligibleSysID(sourceString: string): boolean; + newLinesToBreaks(sourceString: string): string; + normalizeWhitespace(sourceString: string): string; + unescapeHTML(htmlString: string): string; +}; diff --git a/types/servicenow-london/GlideSysAttachment.d.ts b/types/servicenow-london/GlideSysAttachment.d.ts new file mode 100644 index 0000000000..8878cf877f --- /dev/null +++ b/types/servicenow-london/GlideSysAttachment.d.ts @@ -0,0 +1,26 @@ +declare class GlideSysAttachment { + constructor(); + copy( + sourceTable: string, + sourceSysId: string, + destinationTable: string, + destinationSysId: string + ): void; + deleteAttachment(sysId: string): void; + getContent(record: ScopedGlideRecord): any; + getContentBase64(record: ScopedGlideRecord): string; + getContentStream(sysId: string): object; + write(record: ScopedGlideRecord, fileName: string, contentType: string, data: any): string; + writeBase64( + record: ScopedGlideRecord, + fileName: string, + contentType: string, + base64Content: string + ): string; + writeContentStream( + record: ScopedGlideRecord, + fileName: string, + contentType: string, + inputStream: object + ): string; +} diff --git a/types/servicenow-london/GlideSystem.d.ts b/types/servicenow-london/GlideSystem.d.ts new file mode 100644 index 0000000000..77dee48d8f --- /dev/null +++ b/types/servicenow-london/GlideSystem.d.ts @@ -0,0 +1,90 @@ +interface GlideSystem { + addErrorMessage(message: string): void; + addInfoMessage(message: string): void; + base64Decode(source: string): string; + base64Encode(source: string): string; + beginningOfLastMonth(): string; + beginningOfLastWeek(): string; + beginningOfNextWeek(): string; + beginningOfNextMonth(): string; + beginningOfNextYear(): string; + beginningOfThisMonth(): string; + beginningOfThisQuarter(): string; + beginningOfThisWeek(): string; + beginningOfThisYear(): string; + dateGenerate(date: string): string; + daysAgo(days: number): string; + daysAgoEnd(days: number): string; + daysAgoStart(days: number): string; + debug(message: string, parm1?: any, parm2?: any, parm3?: any, parm4?: any, parm5?: any): void; + endOfLastMonth(): string; + endOfLastWeek(): string; + endOfLastYear(): string; + endOfNextMonth(): string; + endOfNextWeek(): string; + endOfNextYear(): string; + endOfThisMonth(): string; + endOfThisQuarter(): string; + endOfThisWeek(): string; + endOfThisYear(): string; + error(message: string, parm1?: any, parm2?: any, parm3?: any, parm4?: any, parm5?: any): void; + eventQueue( + eventName: string, + gr: ScopedGlideRecord, + optionalParam1: string, + optionalParam2: string, + eventQueue?: string + ): void; + eventQueueScheduled( + name: string, + instance: ScopedGlideRecord, + parm1: string, + parm2: string, + expiration: object + ): void; + executeNow(job: ScopedGlideRecord): string; + generateGUID(): string; + getCallerScopeName(): string; + getCssCacheVersionString(): string; + getCurrentApplicationId(): string; + getCurrentScopeName(): string; + getErrorMessages(id: string, args?: string[]): string; + getEscapedMessage(id: string, object?: any): string; + getMessage(id: string, object?: any): string; + getProperty(key: string, altobject?: {}): {}; + getSession(): GlideSession; + getSessionID(): string; + getSessionToken(): string; + getTimeZoneName(): string; + getUrlOnStack(): string; + getUser(): GlideUser; + getUserDisplayName(): string; + getUserID(): string; + getUserName(): string; + getUserNameByUserID(id: string): string; + hasRole(roleName: string): boolean; + hoursAgo(hours: number): string; + hoursAgoEnd(hours: number): string; + hoursAgoStart(hours: number): string; + include(include: string): void; + info(message: any, parm1?: any, parm2?: any, parm3?: any, parm4?: any, parm5?: any): void; + isDebugging(): boolean; + isInteractive(): boolean; + isLoggedIn(): boolean; + isMobile(): boolean; + minutesAgoEnd(num: number): string; + minutesAgoStart(num: number): string; + monthsAgo(num: number): string; + monthsAgoEnd(num: number): string; + monthsAgoStart(num: number): string; + nil(object: any): boolean; + quartersAgoEnd(num: number): string; + quartersAgoStart(num: number): string; + setProperty(key: string, value: string, description: string): void; + setRedirect(uri: string): void; + tableExists(table: string): boolean; + warn(message: string, parm1?: any, parm2?: any, parm3?: any, parm4?: any, parm5?: any): void; + xmlToJSON(xml: string): any; + yearsAgo(years: number): string; + yesterday(): string; +} diff --git a/types/servicenow-london/GlideTime.d.ts b/types/servicenow-london/GlideTime.d.ts new file mode 100644 index 0000000000..d51854e7a6 --- /dev/null +++ b/types/servicenow-london/GlideTime.d.ts @@ -0,0 +1,171 @@ +/** + * The scoped GlideTime class provides methods for performing operations on GlideTime + * objects, such as instantiating GlideTime objects or working with GlideTime fields. + */ +declare class GlideTime { + /** + * Instantiates a GlideTime object with the current time. + * + * @example + * + * var gt = new GlideTime(); + * gs.info(gt.getDisplayValue()); + */ + constructor(); + + /** + * Instantiates a GlideTime object with the specified time. + * + * @example + * + * var gt = new GlideTime(10000); + * gs.info(gt.getDisplayValue()); + */ + constructor(milliseconds: number); + + /** + * Gets the time in the specified format. + * + * @param format The time format. + * @returns The time in the specified format. + * @example + * + * var gt = new GlideTime(); + * gt.setValue('12:00:00'); + * gs.info(gt.getByFormat("HH:mm")); + */ + getByFormat(format: string): string; + + /** + * Gets the time in the current user's display format and time zone. + * + * @returns The time in the user's format and time zone. + * @example + * + * var gt = new GlideTime(); + * gt.setDisplayValue("12:00:00"); // User Time Zone + * gs.info(gt.getDisplayValue()); // User Time Zone + */ + getDisplayValue(): string; + + /** + * Gets the display value in the current user's time zone and the internal format + * (HH:mm:ss). + * + * @returns The time value for the GlideTime object in the current user's time zone and the + * internal time format of HH:mm:ss. + * @example + * + * var gt = new GlideTime(); + * gt.setValue("01:00:00"); //Internal Time Zone , UTC + * gs.info(gt.getDisplayValueInternal()); //User Time Zone + */ + getDisplayValueInternal(): string; + + /** + * Returns the hours part of the time using the local time zone. + * + * @returns The hours using the local time zone. + */ + + getHourLocalTime(): number; + + /** + * Returns the hours part of the time using the local time zone. The number of hours is + * based on a 24 hour clock. + * + * @returns The hours using the local time zone. The number of hours is based on a 24 hour + * clock. + */ + getHourOfDayLocalTime(): number; + + /** + * Returns the hours part of the time using the UTC time zone. The number of hours is + * based on a 24 hour clock. + * + * @returns The hours using the UTC time zone. The number of hours is based on a 24 hour + * clock. + */ + getHourOfDayUTC(): number; + /** + * Returns the hours part of the time using the UTC time zone. The number of hours is + * based on a 12 hour clock. Noon and midnight are represented by 0, not 12. + * + * @returns The hours using the UTC time zone. The number of hours is based on a 12 hour + * clock. Noon and midnight are represented by 0, not 12. + */ + getHourUTC(): number; + /** + * Returns the number of minutes using the local time zone. + * + * @returns The number of minutes using the local time zone. + */ + getMinutesLocalTime(): number; + /** + * Returns the number of minutes in the hour based on the UTC time zone. + * + * @returns The number of minutes in the hour using the UTC time zone. + */ + getMinutesUTC(): number; + /** + * Returns the number of seconds in the current minute. + * + * @returns The number of seconds in the minute. + */ + getSeconds(): number; + /** + * Gets the time value stored in the database by the GlideTime object in the internal + * format, HH:mm:ss, and the system time zone. + * + * @returns The time value in the internal fomat and system time zone. + * @example + * + * var gt = new GlideTime(); + * gs.info(gt.getValue()); // Internal Time Zone, UTC + */ + getValue(): string; + + /** + * Sets a time value using the current user's display format and time zone. + * + * @param asDisplayed The time in the current user's display format and time zone. The parameter + * must be formatted using the current user's preferred display format, such as HH:mm:ss. + * @returns Method does not return a value + * @example + * + * var gt = new GlideTime(); + * gt.setDisplayValue('01:00:00'); // User Time Zone + * gs.info(gt.getDisplayValueInternal()); // User Time Zone + */ + setDisplayValue(asDisplayed: string): void; + + /** + * Sets the time of the GlideTime object in the internal time zone. + * + * @param o The time in hh:mm:ss format. + * @returns Method does not return a value + * @example + * + * var gt = new GlideTime(); + * gt.setValue('01:00:00'); //Internal Time Zone, UTC + * gs.info("time is "+ gt.getByFormat('hh:mm:ss')); + */ + setValue(o: string): void; + + /** + * Gets the duration difference between two GlideTime object values. + * + * @param startTime The start value. + * @param endTime The end value. + * @returns The duration between the two values. + * @example + * + * var gd1 = new GlideTime(); + * gd1.setDisplayValue("09:00:00"); + * var gd2 = new GlideTime(); + * gd2.setDisplayValue("09:10:00"); + * var dur = GlideDate.subtract(gd1, gd2); //the difference between gdt1 and gdt2 + * gs.info(dur.getDisplayValue()); + */ + subtract(start: GlideTime, end: GlideTime): GlideDuration; +} diff --git a/types/servicenow-london/GlideUser.d.ts b/types/servicenow-london/GlideUser.d.ts new file mode 100644 index 0000000000..f3aeddc83d --- /dev/null +++ b/types/servicenow-london/GlideUser.d.ts @@ -0,0 +1,16 @@ +interface GlideUser { + getCompanyID(): string; + getDisplayName(): string; + getDomainID(): string; + getEmail(): string; + getFirstName(): string; + getID(): string; + getLastName(): string; + getName(): string; + getPreference(name: string): string; + getRoles(): string[]; + getUserRoles(): string[]; + hasRole(role: string): boolean; + isMemberOf(group: string): boolean; + savePreference(name: string, value: string): void; +} diff --git a/types/servicenow-london/QueryOperator.d.ts b/types/servicenow-london/QueryOperator.d.ts new file mode 100644 index 0000000000..a378e98f18 --- /dev/null +++ b/types/servicenow-london/QueryOperator.d.ts @@ -0,0 +1,15 @@ +type QueryOperator = + | '=' + | '!=' + | '>' + | '>=' + | '<' + | '<=' + | 'IN' + | 'NOT IN' + | 'STARTSWITH' + | 'ENDSWITH' + | 'CONTAINS' + | 'DOES NOT CONTAIN' + | 'INSTANCEOF' + | 'SAMEAS'; diff --git a/types/servicenow-london/RESTAPIRequest.d.ts b/types/servicenow-london/RESTAPIRequest.d.ts new file mode 100644 index 0000000000..536123baae --- /dev/null +++ b/types/servicenow-london/RESTAPIRequest.d.ts @@ -0,0 +1,13 @@ +declare namespace sn_ws { + interface RESTAPIRequest { + readonly body: RESTAPIRequestBody; + readonly pathParams: { [paramName: string]: string }; + readonly queryParams: { [paramName: string]: string[] }; + readonly queryString: string; + readonly uri: string; + readonly url: string; + readonly headers: { [paramName: string]: string }; + getHeader(header: string): string; + getSupportedResponseContentTypes(): string[]; + } +} diff --git a/types/servicenow-london/RESTAPIRequestBody.d.ts b/types/servicenow-london/RESTAPIRequestBody.d.ts new file mode 100644 index 0000000000..76e24c38dc --- /dev/null +++ b/types/servicenow-london/RESTAPIRequestBody.d.ts @@ -0,0 +1,9 @@ +declare namespace sn_ws { + interface RESTAPIRequestBody { + readonly data: any; + readonly dataStream: object; + readonly dataString: string; + hasNext(): boolean; + nextEntry(): any; + } +} diff --git a/types/servicenow-london/RESTAPIResponse.d.ts b/types/servicenow-london/RESTAPIResponse.d.ts new file mode 100644 index 0000000000..430d56048a --- /dev/null +++ b/types/servicenow-london/RESTAPIResponse.d.ts @@ -0,0 +1,12 @@ +declare namespace sn_ws { + interface RESTAPIResponse { + getStreamWriter(): RESTAPIResponseStream; + setBody(body: any): void; + setHeaders(headers: any): void; + setLocation(location: string): void; + setStatus(status: number): void; + setHeader(header: string, value: string): void; + setContentType(contentType: string): void; + setError(error: any): void; + } +} diff --git a/types/servicenow-london/RESTAPIResponseStream.d.ts b/types/servicenow-london/RESTAPIResponseStream.d.ts new file mode 100644 index 0000000000..c98d0eecfd --- /dev/null +++ b/types/servicenow-london/RESTAPIResponseStream.d.ts @@ -0,0 +1,6 @@ +declare namespace sn_ws { + interface RESTAPIResponseStream { + writeStream(stream: object): void; + writeString(data: string): void; + } +} diff --git a/types/servicenow-london/RESTMessageV2.d.ts b/types/servicenow-london/RESTMessageV2.d.ts new file mode 100644 index 0000000000..fadac635aa --- /dev/null +++ b/types/servicenow-london/RESTMessageV2.d.ts @@ -0,0 +1,581 @@ +declare namespace sn_ws { + /** + * The RESTMessageV2 API allows you to send outbound REST messages using JavaScript. + * Use the RESTResponseV2 API to manage the response returned by the REST provider. + * + * You can use this API in scoped applications, or within the global scope. + */ + class RESTMessageV2 { + /** + * Instantiates an empty RESTMessageV2 object. + * + * When using an object instantiated this way, you must manually specify an HTTP method an + * endpoint. + * @example + * + * var sm = new sn_ws.RESTMessageV2(); + */ + constructor(); + + /** + * Instantiates a RESTMessageV2 object using information from a REST message record. + * + * You must have a REST message record defined before you can use this constructor. + * + * In the following example, replace `REST_message_record` with the name of the REST message + * record from your instance. + * + * @param name The name of the REST message record. + * @param methodName The name of the HTTP method to use, such as GET or PUT. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + */ + constructor(name: string, methodName: RestHTTPMethods); + + /** + * Send the REST message to the endpoint. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @returns The response returned by the REST provider. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * // Might throw exception if http connection timed out or some issue with sending request + * // itself because of encryption/decryption of password. + * var response = sm.execute(); + */ + execute(): RESTResponseV2; + + /** + * Send the REST message to the endpoint asynchronously. The instance does not wait for a + * response from the web service provider when making asynchronous calls. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @returns The response returned by the REST provider. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * // Might throw exception if http connection timed out or some issue with sending request + * // itself because of encryption/decryption of password. + * var response = sm.executeAsync(); + * // In seconds. Wait at most 60 seconds to get response from ECC Queue/Mid Server + * // Might throw exception timing out waiting for response in ECC queue. + * response.waitForResponse(60); + */ + executeAsync(): RESTResponseV2; + + /** + * Get the URL of the endpoint for the REST message. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @returns The URL of the REST web service provider. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * var endpoint = sm.getEndpoint(); + */ + getEndpoint(): string; + + /** + * Get the content of the REST message body. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @returns The REST message body. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * var body = sm.getRequestBody(); + */ + getRequestBody(): string; + + /** + * Get the value for an HTTP header specified in the REST message. + * + * By default, this method cannot return the value for a header set automatically by the system. + * To grant this method access to all headers, set the property glide.http.log_debug to true. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param headerName The request header you want to get the value for. + * @returns The value of the specified header. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * var header = sm.getRequestHeader("Accept"); + */ + getRequestHeader(headerName: string): string; + + /** + * Get HTTP headers that were set by the REST client and the associated values. + * + * This method does not return headers set automatically by the system. To configure this + * method to return all headers, set the property glide.http.log_debug to true. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @returns An Object that maps the name of each header to the associated value. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * var headers = sm.getRequestHeaders(); + */ + getRequestHeaders(): object; + + /** + * Configures the REST message to save the returned response body as an attachment record. + * + * When you use this function with a REST message that is sent through a MID server, the MID + * server user must have any roles required to read and write attachment records, as well as + * any roles required to read and write records on the table specified in the tableName + * parameter. + * + * The response body does not need to be a binary file to be saved as an attachment. Response + * bodies using text formats, such as JSON or XML can also be saved. If the instance fails + * to save the attachment, call getErrorMessage() on the related RESTResponseV2 object + * for error details. + * + * @param tableName Specify the table that contains the record you want to attach the saved file + * to. + * @param recordSysId Specify the sys_id of the record you want to attach the saved file to. + * @param fileName Specify the file name to give to the saved file. + * @example + * + * (function sampleRESTMessageV2() { + * try { + * var request = new sn_ws.RESTMessageV2(); + * request.setHttpMethod('get'); + * + * var attachment_sys_id = '', + * tablename = 'incident', + * recordSysId = '', + * response, + * httpResponseStatus, + * filename = ''; + * + * // endpoint - ServiceNow REST Attachment API + * request.setEndpoint('https://.service-now.com/api/now/attachment/' + + * attachment_sys_id + '/file'); + * request.setBasicAuth('', ''); + * + * // RESTMessageV2 - saveResponseBodyAsAttachment(String tableName, String recordSysId, + * // String fileName) + * request.saveResponseBodyAsAttachment(tablename, recordSysId, filename); + * + * response = request.execute(); + * httpResponseStatus = response.getStatusCode(); + * + * gs.print(" http response status_code: " + httpResponseStatus); + * } + * catch (ex) { + * var message = ex.getMessage(); + * gs.print(message); + * } + * })(); + */ + saveResponseBodyAsAttachment( + tableName: string, + recordSysId: string, + fileName: string + ): void; + + /** + * Configure the REST message to save the returned response body as an encrypted + * attachment record. + * + * When you use this function with a REST message that is sent through a MID server, the MID + * server user must have any roles required to read and write attachment records, as well as any + * roles required to read and write records on the table specified in the `tableName` parameter. + * + * The response body does not need to be a binary file to be saved as an attachment. Response + * bodies using text formats, such as JSON or XML can also be saved. If the instance fails to + * save the attachment, call `getErrorMessage()` on the related RESTResponseV2 object for error + * details. + * + * @param tableName Specify the table that contains the record you want to attach the saved file + * to. + * @param recordSysId Specify the sys_id of the record you want to attach the saved file to. + * @param fileName Specify the file name to give to the saved file. + * @param encryptContext Specify the sys_id of an encryption context. The saved file is + * encrypted using this context. + */ + + saveResponseBodyAsAttachment( + tableName: string, + recordSysId: string, + fileName: string, + encryptContext: string + ): void; + + /** + * Set the credentials for the REST message using an existing basic auth or OAuth 2.0 profile. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param type The type of authentication profile to use. Valid values are 'basic' to use basic + * authentication, or 'oauth2' to use OAuth 2.0. + * @param profileId The sys_id of an authentication profile record. When using basic auth, + * specify the sys_id of a Basic Auth Configuration [sys_auth_profile_basic] record. When using + * OAuth 2.0, specify the sys_id of a OAuth Entity Profile [oauth_entity_profile] record. + * @example + * + * var requestBody; + * var responseBody; + * var status; + * var sm; + * try { + * // Might throw exception if message doesn't exist or not visible due to scope. + * sm = new sn_ws.RESTMessageV2("", "get"); + * + * // set auth profile to an OAuth 2.0 profile record. + * sm.setAuthenticationProfile('oauth2', '1234adsf123212131123qasdsf'); + * + * sm.setStringParameter("symbol", "NOW"); + * sm.setStringParameterNoEscape("xml_data", "test"); + * + * // In milliseconds. Wait at most 10 seconds for response from http request. + * sm.setHttpTimeout(10000); + * // Might throw exception if http connection timed out or some issue + * // with sending request itself because of encryption/decryption of password. + * response = sm.execute(); + * responseBody = response.haveError() ? response.getErrorMessage() : response.getBody(); + * status = response.getStatusCode(); + * } catch (ex) { + * responseBody = ex.getMessage(); + * status = '500'; + * } finally { + * requestBody = sm ? sm.getRequestBody() : null; + * } + */ + setAuthenticationProfile(type: string, profileId: string): void; + + /** + * Sets basic authentication headers for the REST message. + * + * Setting security values using this method overrides basic authentication values defined for + * the REST message record. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param userName The username you want to use to authenticate the REST message. + * @param userPass The password for the specified user. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setBasicAuth("username","password"); + */ + setBasicAuth(userName: string, userPass: string): void; + + /** + * Associate outbound requests and the resulting response record in the ECC queue. This method + * only applies to REST messages sent through a MID Server. + * + * The correlator provided populates the Agent correlator field on the ECC queue record for the + * response. Provide a unique correlator for each outbound request to associate the correct + * results in the ECC queue with the request when designing asynchronous automation through a + * MID Server. + * + * In the following example, replace REST_message_record with the name of the REST message record + * from your instance. + * + * @param correlator A unique identifier + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setEccCorrelator("unique_identifier"); + */ + setEccCorrelator(correlator: string): void; + + /** + * Override a value from the database by writing to the REST message payload. This method only + * applies to REST messages sent through a MID Server. + * + * Use this method when a value from the REST message in the database is invalid, such as when + * the endpoint URL is longer than the maximum REST endpoint field length. You can set only the + * endpoint URL using this method by passing source as the name parameter. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param name The name of the parameter, such as source. + * @param value The value to assign to the specified parameter. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setEccParameter("source","http://very.long.endpoint.url"); + */ + setEccParameter(name: string, value: string): void; + + /** + * Set the endpoint for the REST message. + * + * By default, the REST message uses the endpoint specified in the REST message record. Use this + * method to override this default. You must call this method when using the RESTMessageV2 - + * + * RESTMessageV2() constructor with no parameters. + * + * @param endpoint The URL of the REST provider you want to interface with. + * @example + * + * var sm = new sn_ws.RESTMessageV2(); + * sm.setEndpoint("http://web.service.endpoint"); + */ + setEndpoint(endpoint: string): void; + + /** + * The HTTP method this REST message performs, such as GET or PUT. + * + * You must set an HTTP method when using the RESTMessageV2 - RESTMessageV2() constructor with + * no parameters. + * @param method The HTTP method to perform. + * @example + * + * var sm = new sn_ws.RESTMessageV2(); + * sm.setHttpMethod("post"); + */ + setHttpMethod(method: RestHTTPMethods): void; + + /** + * Set the amount of time the REST message waits for a response from the web service provider + * before the request times out. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param timeoutMs The amount of time, in milliseconds, before the call to the REST provider + * times out. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setHttpTimeout(6000); + */ + setHttpTimeout(timeoutMs: number): void; + + /** + * Set the log level for this message and the corresponding response. + * + * Setting a log level using the RESTMessageV2 API overrides the log level configured on the + * REST message record. This log level may not apply if the endpoint domain is blacklisted, or + * if the property glide.outbound_http_log.override is true. To view outbound web service logs, + * navigate to System Logs > Outbound HTTP Requests. + * + * @param level The log level. Valid values are basic, elevated, and all. + * @example + * + * var rm = new sn_ws.RESTMessageV2(); + * rm.setLogLevel('all'); + */ + setLogLevel(level: 'basic' | 'elevated' | 'all'): void; + + /** + * Configure the REST message to communicate through a MID Server. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param midServer The name of the MID Server to use. Your instance must have an active MID + * Server with the specified name. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setMIDServer("mid_server_name"); + */ + setMIDServer(midServer: string): void; + + /** + * Set the mutual authentication protocol profile for the REST message. + * + * Setting a protocol profile using this method overrides the protocol profile selected for the + * REST message record. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param profileName The Name of the protocol profile to use for mutual authentication. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setMutualAuth("mutual_auth_profile_name"); + */ + setMutualAuth(profileName: string): void; + + /** + * Append a parameter to the end of the request URL with the form name=value. + * + * For example, the code setQueryParameter("sysparm_query", + * "active=true^ORDERBYnumber^ORDERBYDESCcategory"); appends the text + * + * sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory to the request URL. + * + * @param name The name of the URL parameter to pass. + * @param value The value to assign the URL parameter. + * @example + * + * var sm = new sn_ws.RESTMessageV2(); + * // Set up message, including endpoint and authentication + * sm.setQueryParameter("sysparm_query","active=true^ORDERBYnumber^ORDERBYDESCcategory"); + */ + setQueryParameter(name: string, value: string): void; + + /** + * Set the body content to send to the web service provider when using PUT or POST HTTP methods. + * + * When you set the body content using this method, variables in the body are not substituted + * for parameters from the REST message function record. You must explicitly define all values + * within the REST message body. + * + * @param body The request body to send. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("Update user","post"); + * var body = ""; + * sm.setRequestBody(body); + */ + setRequestBody(body: string): void; + + /** + * Sets the request body using an existing attachment record. + * + * When you use this function with a REST message that is sent through a MID server, the MID + * server user must have any roles required to read attachment records. + * + * @param attachmentSysId The sys_id of the Attachment [sys_attachment] record you want to send + * in this REST message. + * @example + * + * (function sampleRESTMessageV2() { + * try { + * var request = new sn_ws.RESTMessageV2(); + * request.setHttpMethod('post'); + * request.setEndpoint(''); + * request.setRequestBodyFromAttachment(''); + * + * var response = request.execute(); + * var httpResponseStatus = response.getStatusCode(); + * + * gs.print("http response status_code: " + httpResponseStatus); + * } + * catch (ex) { + * var message = ex.getMessage(); + * gs.print(message); + * } + * })(); + */ + setRequestBodyFromAttachment(attachmentSysId: string): void; + + /** + * Set the body content of a PUT or POST message using a binary stream. + * + * You can use this method to send binary files such as images or archives using REST messages. + * If the request is not a PUT or POST request, the request body is ignored. + * + * @param stream The binary data to send, such as an attachment or a stream from a 3rd-party + * service. + */ + setRequestBodyFromStream(stream: object): void; + + /** + * Set an HTTP header in the REST message to the specified value. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param name The name of the header. + * @param value The value to assign to the specified header. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setRequestHeader("Accept","Application/json"); + */ + setRequestHeader(name: string, value: string): void; + + /** + * Override the default requestor profile for the REST message in order to retrieve an OAuth + * access token associated with a different requestor. + * + * This method applies only to REST messages configured to use OAuth 2.0 authentication. This + * method is optional and is unnecessary in most configurations. + * + * @param requestorContext + * @param requestorId + */ + setRequestorProfile(requestorContext: string, requestorId: string): void; + + /** + * Set a REST message function variable with the specified name from the REST message record + * to the specified value. + * + * XML reserved characters in the value are converted to the equivalent escaped characters. Use + * setStringParameterNoEscape to set a variable without escaping XML reserved characters. + * + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param name The name of the REST message variable. This parameter must be defined in the + * REST message record before you can assign a value to it. + * @param value The value to assign the variable. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setStringParameter("s","NOW"); + */ + setStringParameter(name: string, value: string): void; + + /** + * Set a REST message function variable with the specified name from the REST message record to + * the specified value. + * + * This method is equivalent to setStringParameter but does not escape XML reserved characters. + * In the following example, replace REST_message_record with the name of the REST message + * record from your instance. + * + * @param name The name of the REST message variable. This parameter must be defined in the + * REST message record before you can assign a value to it. + * @param value The value to assign the variable. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2("","get"); + * sm.setStringParameterNoEscape("s","NOW"); + */ + setStringParameterNoEscape(name: string, value: string): void; + } + + type RestHTTPMethods = + | 'get' + | 'post' + | 'delete' + | 'patch' + | 'put' + | 'head' + | 'delete' + | 'options'; +} diff --git a/types/servicenow-london/RESTResponseV2.d.ts b/types/servicenow-london/RESTResponseV2.d.ts new file mode 100644 index 0000000000..76f42acf71 --- /dev/null +++ b/types/servicenow-london/RESTResponseV2.d.ts @@ -0,0 +1,188 @@ +declare namespace sn_ws { + /** + * The RESTResponseV2 API allows you to use the data returned by an outbound REST message + * in JavaScript code. + */ + class RESTResponseV2 { + /** + * Returns all headers contained in the response, including any duplicate headers. + * + * @returns The list of headers contained in the response. Each header is represented as a + * GlideHTTPHeader object which contains the header `name` and `value`. + * @example + * + * var r = new sn_ws.RESTMessageV2('', 'get'); + * var response = r.execute(); + * var headers = response.getAllHeaders(); + * for(var i in headers){ + * gs.info(headers[i].name + ': ' + headers[i].value); + * } + */ + getAllHeaders(): [{ name: string; value: string }]; + + /** + * Get the content of the REST response body. + * + * Use this function when you want to get the request body as text content. Do not use this + * method when saving the response as a binary attachment. If a RESTMessageV2 object called + * the `saveResponseBodyAsAttachment(...)` function, using `getBody()` on the associated + * RESTResponseV2 object will cause an error. When saving the response as an attachment, + * if the outbound REST message fails, call `getErrorMessage()` on the response to retrieve + * the body content. + * + * @returns The REST response body. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var responseBody = response.getBody(); + */ + getBody(): string; + + /** + * Returns all cookies included in the response. + * + * @returns The list of cookies. Iterate through the list to perform operations on each cookie. + * @example + * + * var cookies = response.getCookies(); + * var i; + * for (var i = 0; i < cookies.size(); i++) { + * gs.info('cookie: ' + cookies.get(i)); + * } + */ + getCookies(): { size: () => number; get: (index: number) => string }; + + /** + * Get the numeric error code if there was an error during the REST transaction. + * + * This error code is specific to the Now Platform, it is not an HTTP error code. Provide this + * error code if you require assistance from ServiceNow Customer Support. + * + * @returns The numeric error code, such as 1 for socket timeout. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var errorCode = response.getErrorCode(); + */ + getErrorCode(): number; + + /** + * Get the error message if there was an error during the REST transaction. + * + * @returns The error message. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var errorMsg = response.getErrorMessage(); + */ + getErrorMessage(): string; + + /** + * Get the value for a specified header. + * + * @param name The name of the header that you want the value for, such as Set-Cookie. + * @returns The value of the specified header. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var headerVal = response.getHeader('Content-Type'); + */ + getHeader(name: string): string; + + /** + * Get all headers returned in the REST response and the associated values. + * + * **Note:** If a header is present more than once in the response, such as a Set-Cookie header, + * this function returns only the last of the duplicate headers. To return all headers + * including duplicates, use the `getAllHeaders()` function. + * + * @returns An Object that maps the name of each header to the associated value. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var headers = response.getHeaders(); + */ + getHeaders(): object; + + /** + * Get the fully-resolved query sent to the REST endpoint. + * + * This query contains the endpoint URL as well as any values assigned to variables in the + * REST message. Use this method only with responses to direct requests. This method is not + * supported for requests sent asynchronously, or requests sent using a MID server. + * + * @returns The fully-resolved query. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var queryString = response.getQueryString(); + */ + getQueryString(): string; + + /** + * Get the sys_id value of the attachment created from the response body content. + * + * If the RESTMessageV2 object associated with this response called the + * `saveResponseBodyAsAttachment(...)` function, use `getResponseAttachmentSysid()` to get the + * sys_id of the created attachment record. Use this function when you want to perform + * additional operations with the new attachment record. + * + * @returns The sys_id of the new attachment record. + */ + getResponseAttachmentSysid(): string; + + /** + * Get the numeric HTTP status code returned by the REST provider. + * + * @returns The numeric status code returned by the REST provider, such as 200 for a + * successful response. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var statusCode = response.getStatusCode(); + */ + getStatusCode(): number; + + /** + * Indicate if there was an error during the REST transaction. + * + * @returns Returns true if there was an error, false if there was no error. + * @example + * + * // Might throw exception if message doesn't exist or not visible due to scope. + * var sm = new sn_ws.RESTMessageV2('Yahoo Finance', 'get'); + * var response = sm.execute(); + * var error = response.haveError(); + */ + haveError(): boolean; + + /** + * Set the amount of time the instance waits for a response from the web service provider. + * + * This method overrides the property glide.rest.outbound.ecc_response.timeout for this REST + * response. + * + * @param timeoutSecs The amount of time, in seconds, to wait for this response. + * @example + * + * var sm = new sn_ws.RESTMessageV2("Yahoo Finance","get"); //Might throw exception if message doesn't exist or not visible due to scope. + * var response = sm.executeAsync(); + * response.waitForResponse(60); + */ + waitForResponse(timeoutSecs: number): void; + } +} diff --git a/types/servicenow-london/RenderProperties.d.ts b/types/servicenow-london/RenderProperties.d.ts new file mode 100644 index 0000000000..ade2ebe4a5 --- /dev/null +++ b/types/servicenow-london/RenderProperties.d.ts @@ -0,0 +1,13 @@ +interface RenderProperties { + getEncodedQuery(): string; + getListControl(): any; + getParameters(): string[]; + getParameterValue(value: string): string; + getReferringURL(): string; + getViewName(): string; + getWindowProperties(): any; + isInDevStudio(): boolean; + isInteractive(): boolean; + isManyToMany(): boolean; + isRelatedList(): boolean; +} diff --git a/types/servicenow-london/SOAPMessageV2.d.ts b/types/servicenow-london/SOAPMessageV2.d.ts new file mode 100644 index 0000000000..0b935f5406 --- /dev/null +++ b/types/servicenow-london/SOAPMessageV2.d.ts @@ -0,0 +1,31 @@ +declare namespace sn_ws { + class SOAPMessageV2 { + constructor(); + constructor(soapMessage: string, soapFunction: string); + execute(): SOAPResponseV2; + executeAsync(): SOAPResponseV2; + setHttpMethod(method: string): void; + setHttpTimeout(timeoutMs: number): void; + setBasicAuth(userName: string, userPass: string): void; + setMutualAuth(profileName: string): void; + setEccCorrelator(correlator: string): void; + setEccParameter(name: string, value: string): void; + setEndpoint(endpoint: string): void; + setMIDServer(midServer: string): void; + setRequestBody(body: string): void; + setRequestHeader(name: string, value: string): void; + setSOAPAction(soapAction: string): void; + setStringParameter(name: string, value: string): void; + setStringParameterNoEscape(name: string, value: string): void; + setWSSecurity( + keystoreId: string, + keystoreAlias: string, + keystorePassword: string, + certificateId: string + ): void; + getRequestBody(): string; + getEndpoint(): string; + getRequestHeader(headerName: string): string; + getRequestHeaders(): object; + } +} diff --git a/types/servicenow-london/SOAPResponseV2.d.ts b/types/servicenow-london/SOAPResponseV2.d.ts new file mode 100644 index 0000000000..4d8020c918 --- /dev/null +++ b/types/servicenow-london/SOAPResponseV2.d.ts @@ -0,0 +1,14 @@ +declare namespace sn_ws { + interface SOAPResponseV2 { + getAllHeaders(): [{ name: string; value: string }]; + getBody(): string; + getCookies(): { size: () => number; get: (index: number) => string }; + getErrorCode(): number; + getErrorMessage(): string; + getHeader(name: string): string; + getHeaders(): object; + getStatusCode(): number; + haveError(): boolean; + waitForResponse(timeoutSecs: number): void; + } +} diff --git a/types/servicenow-london/ScopedElementDescriptor.d.ts b/types/servicenow-london/ScopedElementDescriptor.d.ts new file mode 100644 index 0000000000..da5de57c32 --- /dev/null +++ b/types/servicenow-london/ScopedElementDescriptor.d.ts @@ -0,0 +1,227 @@ +/** + * The scoped GlideElementDescriptor API provides information about individual fields. + * + * There is no constructor for this class. Use the GlideElement `getED()` method to obtain a + * GlideElementDescriptor object. + * + * Actual type com.glide.db.ElementDescriptor (JavaObject). + */ +interface ScopedElementDescriptor { + /** + * Returns the encryption type used for attachments on the element's table. + * + * @returns The encryption type used on attachments. Returns null if attachments on the element's + * table are not being encrypted. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.getAttachmentEncryptionType(); + * gs.info(isEdge); + * // null + */ + getAttachmentEncryptionType(): string; + + /** + * Returns the element's encryption type. + * + * @returns The element's encryption type. Returns null if the element is not + * encrypted. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * sEdge = ed.getEncryptionType(); + * gs.info(isEdge); + * // null + */ + getEncryptionType(): string; + + /** + * Returns the element's internal data type. + * + * @returns The element's internal data type. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.getInternalType(); + * gs.info(isEdge); + */ + getInternalType(): string; + + /** + * Returns the element's label. + * + * @returns The element's label. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.getLabel(); + * gs.info(isEdge); + * // Priority + */ + getLabel(): string; + + /** + * Returns the element's length. + * + * @returns The element's size. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.getLength(); + * gs.info(isEdge); + * // 40 + */ + getLength(): number; + + /** + * Returns the element's name. + * + * @returns The element's name. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.getName(); + * gs.info(isEdge); + * // priority + */ + getName(): string; + + /** + * Returns the element's plural label. + * + * @returns The element's plural label. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.query(); + * var ed = gr.getED(); + * gs.info(ed.getPlural()); + * // Incidents + */ + getPlural(): string; + + /** + * Returns true if an encrypted attachment has been added to the table. + * + * @returns Returns true if an encrypted attachment has been added to the table. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.hasAttachmentsEncrypted(); + * gs.info(isEdge); + * // false + */ + hasAttachmentsEncrypted(): boolean; + + /** + * Returns true if the element is an automatically generated or system field. + * + * @returns True if the element is automatically generated or a system field. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * isEdge = ed.isAutoOrSysID(); + * gs.info(isEdge); + * // false + */ + isAutoOrSysID(): boolean; + + /** + * Returns true if the element is defined as a dropdown choice in its dictionary + * definition. + * + * @returns Returns true if the element is defined as a dropdown choice. Returns true even + * if there are no entries defined in the choice table. The last choice type, + * suggestion, does not return true. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isChoiceTable = ed.isChoiceTable(); + * gs.info(isChoiceTable); + * // true + */ + isChoiceTable(): boolean; + + /** + * Returns true if an element is encrypted. + * + * @returns Returns true if the element is encrypted, false otherwise. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isEdge = ed.isEdgeEncrypted(); + * gs.info(isEdge) + * // false + */ + isEdgeEncrypted(): boolean; + + /** + * Returns true if the element is a virtual element. + * + * A virtual element is a calculated field as set by the dictionary definition of the field. + * Virtual fields cannot be encrypted. + * + * @returns Returns true if the element is a virtual element. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + * + * var isVirtual = ed.isVirtual(); + * gs.info(isVirtual); + * // false + */ + isVirtual(): boolean; +} diff --git a/types/servicenow-london/ScopedGlideElement.d.ts b/types/servicenow-london/ScopedGlideElement.d.ts new file mode 100644 index 0000000000..729aa5748d --- /dev/null +++ b/types/servicenow-london/ScopedGlideElement.d.ts @@ -0,0 +1,447 @@ +/** + * The Scoped GlideElement API provides a number of convenient script methods for dealing + * with fields and their values. Scoped GlideElement methods are available for the fields of the + * current GlideRecord. + */ +interface ScopedGlideElement { + /** + * Determines if the user's role permits the creation of new records in this field. + * + * @returns True if the field can be created, false otherwise. + */ + canCreate(): boolean; + + /** + * Indicates whether the user's role permits them to read the associated GlideRecord. + * + * @returns True if the field can be read, false otherwise. + */ + canRead(): boolean; + + /** + * Determines whether the user's role permits them to write to the associated GlideRecord. + * + * @returns True if the user can write to the field, false otherwise. + */ + canWrite(): boolean; + + /** + * Determines if the current field has been modified. This functionality is available for all + * available data types, except Journal fields. + * + * **Note:** The `changes()` method is not supported within ACL scripts. + * + * @returns True if the fields have been changed, false if the field has not. + * @example + * + * // This method is often used in business rules. The following example shown is from a business + * // rule, if "assigned_to" field value is changed, create a event in the EventQueue. + * if (!current.assigned_to.nil() && current.assigned_to.changes()) { + * gs.eventQueue( + * 'incident.assigned', + * current, + * current.assigned_to.getDisplayValue(), + * previous.assigned_to.getDisplayValue() + * ); + * } + */ + changes(): boolean; + + /** + * Determines if the previous value of the current field matches the specified object. + * + * **Note:** If the GlideRecord on which you are performing this method has only been initialized + * and read, and has not been written, the underlying before-and-after values are the same. In + * this case, the method returns `false`, as there has been no change to the data store. + * + * @param o An object value to check against the previous value of the current field. + * @returns True if the previous value matches, false if it does not. + * @example + * + * // The following example shows that in a business rule, if "active" field is changed from true, + * // insert a event in the EventQueue. + * if (current.active.changesFrom(true)) { + * gs.eventQueue('incident.inactive', current, current.incident_state, previous.incident_state); + * } + */ + changesFrom(o: any): boolean; + + /** + * Determines if the new value of a field, after a change, matches the specified object. + * + * **Note:** The changesTo() method is not supported within ACL scripts. + * + * @param o An object value to check against the new value of the current field. + * @returns True if the previous value matches, false if it does not. + * @example + * + * // The following example shows that in a business rule, if "active" field is changed to false, + * // insert a event in the EventQueue. + * if (current.active.changesTo(false)) { + * gs.eventQueue('incident.inactive', current, current.incident_state, previous.incident_state); + * } + */ + changesTo(o: any): boolean; + + /** + * Returns the value of the specified attribute from the dictionary. + * + * If the attribute is a boolean attribute, use `getBooleanAttribute(String)` to get the value as + * a boolean rather than as a string. + * + * @param attributeName Attribute name + * @returns Attribute value + * @example + * + * doit(); + * function doit() { + * var gr = new GlideRecord('sys_user'); + * gr.query('user_name', 'admin'); + * if (gr.next()) { + * gs.print('we got one'); + * gs.print(gr.location.getAttribute('tree_picker')); + * } + * } + */ + getAttribute(attributeName: string): string; + + /** + * Returns the Boolean value of the specified attribute from the dictionary. + * + * To get the value as a string, use `getAttribute(string)`. + * + * @param attributeName Attribute name + * @returns Boolean value of the attribute. Returns false if the attribute does not exist. + */ + getBooleanAttribute(attributeName: string): boolean; + + /** + * Generates a choice list for a field. + * + * @param [dependent] Optional: a dependent value + * @returns An array list of choices. + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * + * // urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3 + * var choices = glideRecord.urgency.getChoices(); + * gs.info(choices); + */ + getChoices(dependent?: string): any[]; + + /** + * Returns the choice label for the current choice. + * + * @returns The selected choice's label. + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * + * // urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3 + * var choiceLabel = glideRecord.urgency.getChoiceValue(); + * gs.info(choiceLabel); + * // 1 - High + */ + getChoiceValue(): string; + + /** + * Returns the clear text value for Password (2 way encrypted) fields in scoped + * applications. + * + * @returns The clear text password. + * @example + * + * var tablename = 'x_scoped_app_table' + * var CI = new GlideRecord(tablename); + * CI.addQuery('number', '0001002'); + * CI.query(); + * CI.next(); + * + * var password = CI.password_field + * var decrypted = password.getDecryptedValue(); + * gs.info(decrypted); + */ + getDecryptedValue(): string; + + /** + * Gets the formatted display value of the field. + * + * @param [maxCharacters] Optional: Maximum characters desired + * @returns The display value of the field + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * gs.info(glideRecord.priority.getDisplayValue()); + */ + getDisplayValue(maxCharacters?: number): string; + + /** + * Returns the field's element descriptor. + * + * @returns The field's element descriptor. + * @example + * + * var grInc = new GlideRecord('incident'); + * grInc.query('priority', '1'); + * + * var field = grInc.getElement('priority'); + * var ed = field.getED(); + */ + getED(): ScopedElementDescriptor; + + /** + * Returns the phone number in international format. + * + * @returns The phone number in international format. + */ + getGlobalDisplayValue(): any; + + /** + * Returns the HTML value of a field. + * + * @param [maxChars] Optional. Maximum number of characters to return. + * @returns HTML value for the field. + * @example + * + * var inccause = new GlideRecord('incident'); + * inccause.short_description = current.short_description; + * inccause.comments = current.comments.getHTMLValue(); + * inccause.insert(); + */ + getHTMLValue(maxChars?: number): string; + + /** + * Returns either the most recent journal entry or all journal entries. + * + * @param mostRecent If 1, returns the most recent entry. If -1, returns all journal + * entries. + * @returns For the most recent entry, returns a string that contains the field label, + * timestamp, and user display name of the journal entry. + * + * For all journal entries, returns the same information for all journal entries + * ever entered as a single string with each entry delimited by "\n\n". + * @example + * + * //gets all journal entries as a string where each entry is delimited by '\n\n' + * var notes = current.work_notes.getJournalEntry(-1); + * //stores each entry into an array of strings + * var na = notes.split('\n\n'); + * + * for (var i = 0; i < na.length; i++) + * gs.print(na[i]); + */ + getJournalEntry(mostRecent: number): string; + + /** + * Returns the object label. + * + * @returns Object label + * @example + * + * var gr = new GlideRecord('sc_req_item'); + * gr.addQuery('request', current.sysapproval); + * gr.query(); + * while (gr.next()) { + * var nicePrice = gr.price.toString(); + * if (nicePrice != '') { + * nicePrice = parseFloat(nicePrice); + * nicePrice = nicePrice.toFixed(2); + * } + * template.print( + * gr.number + ': ' + gr.quantity + ' X ' + gr.cat_item.getDisplayValue() + + * ' at $' + nicePrice + ' each \n' + * ); + * template.print(' Options:\n'); + * for (var key in gr.variables) { + * var v = gr.variables[key]; + * if (v.getGlideObject().getQuestion().getLabel() != '' ) { + * template.space(4); + * template.print( + * ' ' + v.getGlideObject().getQuestion().getLabel() + ' = ' + + * v.getDisplayValue() + '\n' + * ); + * } + * } + * } + */ + getLabel(): string; + + /** + * Returns the name of the field. + * + * @returns Field name + */ + getName(): string; + + /** + * Gets the table name for a reference element. + * + * @returns The table name of the reference + * @example + * + * var grINC = new GlideRecord('incident'); + * grINC.query('number', 'INC0010041'); // record assignment group assigned to "CAB Approval" + * if (grINC.next()) { + * // Get the table name + * var tableName = grINC.assignment_group.getReferenceTable(); + * gs.info(tableName); + * } + */ + getReferenceTable(): string; + + /** + * Returns a GlideRecord object for a given reference element. + * + * @returns A GlideRecord object + * @example + * + * var grINC = new GlideRecord('incident'); + * grINC.notNullQuery('caller_id'); + * grINC.query(); + * if (grINC.next()) { + * + * // Get a GlideRecord object for the referenced sys_user record + * var grUSER = grINC.caller_id.getRefRecord(); + * if (grUSER.isValidRecord()) + * gs.print( grUSER.getValue('name') ); + * } + */ + getRefRecord(): ScopedGlideRecord; + + /** + * Returns the name of the table on which the field resides. + * + * @returns Name of the table. The returned value may be different from the table Class + * that the record is in. See Tables and Classes in the product documentation. + * @example + * + * if (current.approver.getTableName() == 'sysapproval_approver') { + * if (current.approver == email.from_sys_id) { + * current.comments = 'reply from: ' + email.from + '\n\n' + email.body_text; + * + * // if it's been cancelled, it's cancelled. + * var doit = true; + * if (current.state == 'cancelled') doit = false; + * + * if (email.body.state != undefined) current.state = email.body.state; + * + * if (doit) current.update(); + * } else { + * gs.log( + * 'Approval for task (' + + * current.sysapproval.getDisplayValue() + + * ') rejected because user sending email (' + + * email.from + + * ') does not match the approver (' + + * current.approver.getDisplayValue() + + * ')' + * ); + * } + * } + */ + getTableName(): string; + + /** + * Determines if a field is null. + * + * @returns True if the field is null or an empty string, false if not. + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * gs.info(glideRecord.state.nil()); + */ + nil(): boolean; + + /** + * Sets the value of a date/time element to the specified number of milliseconds since + * January 1, 1970 00:00:00 GMT. + * + * @param milliseconds Number of milliseconds since 1/1/1970 + * @example + * + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gr.opened_at.setDateNumericValue(10000); + */ + setDateNumericValue(milliseconds: number): void; + + /** + * Sets the display value of the field. + * + * @param value The value to set for the field. + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * + * //change the urgency to 3 + * glideRecord.urgency.setDisplayValue('3 - Low'); + * gs.info(glideRecord.urgency); + */ + setDisplayValue(value: object): void; + + /** + * Adds an error message. Available in Fuji patch 3. + * + * @param errorMessage The error message. + * @returns Method does not return a value + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * glideRecord.short_description.setError('Error text'); + */ + setError(errorMessage: string): void; + + /** + * Sets the field to the specified phone number. + * + * @param phoneNumber The phone number to set. This can be in either the international or local + * format. + * @param strict When true, specifies that the number specified must match the correct format. + * When false, the system attempts to correct an improperly formatted phone + * number. + * @returns True if the value was set. + */ + setPhoneNumber(phoneNumber: any, strict: boolean): boolean; + + /** + * Sets the value of a field. + * + * @param value Object value to set the field to. + * @returns Method does not return a value + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * glideRecord.short_description.setValue('Network failure'); + * gs.info(glideRecord.short_description); + */ + setValue(value: any): void; + + /** + * Converts the value to a string. + * + * @param value Object value to set the field to. + * @returns The value as a string + * @example + * + * var glideRecord = new GlideRecord('incident'); + * glideRecord.query('priority', '1'); + * glideRecord.next(); + * gs.info(glideRecord.opened_at.toString()); + */ + toString(): string; +} diff --git a/types/servicenow-london/ScopedGlideRecord.d.ts b/types/servicenow-london/ScopedGlideRecord.d.ts new file mode 100644 index 0000000000..3e3dfb7bc5 --- /dev/null +++ b/types/servicenow-london/ScopedGlideRecord.d.ts @@ -0,0 +1,898 @@ +/** + * Scoped GlideRecord is used for database operations. + */ +interface ScopedGlideRecord { + readonly sys_created_by: string & ScopedGlideElement; + readonly sys_created_on: GlideDateTime & ScopedGlideElement; + readonly sys_id: string & ScopedGlideElement; + readonly sys_mod_count: number & ScopedGlideElement; + readonly sys_updated_by: string & ScopedGlideElement; + readonly sys_updated_on: GlideDateTime & ScopedGlideElement; + variables: { [name: string]: any }; + [fieldName: string]: any; + + /** + * Creates an instance of the GlideRecord class for the specified table. + * + * @param tableName The table to be used. + * @example + * + * var gr = new GlideRecord('incident'); + */ + new (tableName: string): ScopedGlideRecord; + + /** + * Adds a filter to return active records. + * + * @returns Filter to return active records. + * @example + * + * var inc = new GlideRecord('incident'); + * inc.addActiveQuery(); + * inc.query(); + */ + addActiveQuery(): ScopedQueryCondition; + + /** + * Adds an encoded query to other queries that may have been set. + * + * @param query An encoded query string + * @example + * + * var queryString = "priority=1^ORpriority=2"; + * var gr = new GlideRecord('incident'); + * gr.addEncodedQuery(queryString); + * gr.query(); + * while (gr.next()) { + * gs.addInfoMessage(gr.number); + * } + */ + addEncodedQuery(query: string): void; + + /** + * Applies a pre-defined GlideDBFunctionBuilder object to a record. + * + * @param fun A GlideDBFunctionBuilder object that defines a SQL operation. + * @returns Method does not return a value + * @example + * + * var functionBuilder = new GlideDBFunctionBuilder(); + * var myAddingFunction = functionBuilder.add(); + * myAddingFunction = functionBuilder.field('order'); + * myAddingFunction = functionBuilder.field('priority'); + * myAddingFunction = functionBuilder.build(); + * + * var gr = new GlideRecord('incident'); + * gr.addFunction(myAddingFunction); + * gr.addQuery(myAddingFunction, '<', 5); + * gr.query(); + * while(gr.next()) + * gs.log(gr.getValue(myAddingFunction)); + * + */ + addFunction(fun: string): void; + + /** + * Adds a filter to return records based on a relationship in a related table. + * + * @param joinTable Table name + * @param primaryField (Optional) If other than sys_id, the primary field + * @param joinTableField (Optional) If other than sys_id, the field that joins the tables. + * @returns A filter that lists records where the relationships match. + * @example + * + * var prob = new GlideRecord('problem'); + * prob.addJoinQuery('incident'); + * prob.query(); + * + * @example + * + * // Look for Problem records that have associated Incident records + * var gr = new GlideRecord('problem'); + * var grSQ = gr.addJoinQuery('incident'); + * // Where the Problem records are "active=false" + * gr.addQuery('active', 'false'); + * // And the Incident records are "active=true" + * grSQ.addCondition('active', 'true'); + * // Query + * gr.query(); + * // Iterate and output results + * while (gr.next()) { + * gs.info(gr.getValue('number')); + * } + * + * @example + * + * var gr = new GlideRecord('problem'); + * gr.addJoinQuery('incident', 'opened_by', 'caller_id'); + * gr.query(); + */ + addJoinQuery( + joinTable: string, + primaryField?: string, + joinTableField?: string + ): ScopedQueryCondition; + + /** + * A filter that specifies records where the value of the field passed in the parameter is not + * null. + * + * @param fieldName The name of the field to be checked. + * @returns A filter that specifies records where the value of the field passed in the + * parameter is not null. + * @example + * + * var target = new GlideRecord('incident'); + * target.addNotNullQuery('short_description'); + * // Issue the query to the database to get all records where short_description is not null + * target.query(); + * while (target.next()) { + * // add code here to process the incident record + * } + */ + addNotNullQuery(fieldName: string): ScopedQueryCondition; + + /** + * Adds a filter to return records where the value of the specified field is null. + * + * @param fieldName The name of the field to be checked. + * @returns The query condition added to the GlideRecord. + * @example + * + * var target = new GlideRecord('incident'); + * target.addNullQuery('short_description'); + * // Issue the query to the database to get all records where short_description is null + * target.query(); + * while (target.next()) { + * // add code here to process the incident record + * } + */ + addNullQuery(fieldName: string): ScopedQueryCondition; + + /** + * Provides the ability to build a request, which when executed, returns the rows from the + * specified table, that match the request. + * + * @param name Table field name. + * @param value Value on which to query (not case-sensitive). + * @returns The query condition added to the GlideRecord. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.addQuery('active', true); + * rec.query(); + * while (rec.next()) { + * rec.active = false; + * gs.info('Active incident ' + rec.number + ' closed'); + * rec.update(); + * } + */ + addQuery(name: string, value: any): ScopedQueryCondition; + + /** + * Provides the ability to build a request, which when executed, returns the rows from the + * specified table, that match the request. + * + * @param name Table field name. + * @param operator Query operator. The available values are dependent on the data type of the + * value parameter. + * + * Numbers: + * - = + * - != + * - > + * - >= + * - < + * - <= + * + * Strings (must be in upper case): + * - = + * - != + * - IN + * - NOT IN + * - STARTSWITH + * - ENDSWITH + * - CONTAINS + * - DOES NOT CONTAIN + * - INSTANCEOF + * + * @param value Value on which to query (not case-sensitive). + * @returns The query condition that was added to the GlideRecord. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.addQuery('active', true); + * rec.addQuery('sys_created_on', '>', '2010-01-19 04:05:00'); + * rec.query(); + * while (rec.next()) { + * rec.active = false; + * gs.info('Active incident ' + rec.number + ' closed'); + * rec.update(); + * } + * + * @example Using the IN operator. + * + * var gr = new GlideRecord('incident'); + * gr.addQuery('number','IN','INC00001,INC00002'); + * gr.query(); + * while (gr.next()) { + * //do something.... + * } + */ + addQuery(name: string, operator: QueryOperator, value: any): ScopedQueryCondition; + + /** + * Adds a filter to return records using an encoded query string. + * + * @param query An encoded query string + * @returns The query condition added to the GlideRecord. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.addQuery('active=true'); + * rec.query(); + * while (rec.next()) { + * rec.active = false; + * gs.info('Active incident ' + rec.number + ' closed'); + * rec.update(); + * } + */ + addQuery(query: string): ScopedQueryCondition; + + /** + * Determines if the Access Control Rules, which include the user's roles, permit + * inserting new records in this table. + * + * @returns True if the user's roles permit creation of new records in this + * table. + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.canCreate()); + */ + canCreate(): boolean; + + /** + * Determines if the Access Control Rules, which include the user's roles, permit deleting + * records in this table. + * + * @returns True if the user's roles permit deletions of records in this table. + * @example + * + * var att = new GlideRecord('sys_attachment'); + * gs.info(att.canDelete()); + */ + canDelete(): boolean; + + /** + * Determines if the Access Control Rules, which include the user's roles, permit reading + * records in this table. + * + * @returns True if the user's roles permit reading records from this table. + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.canRead()); + */ + canRead(): boolean; + + /** + * Determines if the Access Control Rules, which include the user's roles, permit editing + * records in this table. + * + * @returns True if the user's roles permit writing to records from this table. + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.canWrite()); + */ + canWrite(): boolean; + + /** + * Sets a range of rows to be returned by subsequent queries. + * + * @param firstRow The first row to include. + * @param lastRow The last row to include. + * @param forceCount If true, the getRowCount() method will return all possible records. + * @returns Method does not return a value + * @example + * + * var gr = new GlideRecord('incident'); + * gr.orderBy('number'); + * gr.chooseWindow(2, 4); + * gr.query(); + * if (gr.next()) { + * gs.info(gr.number + ' is within window'); + * } + */ + chooseWindow(firstRow: number, lastRow: number, forceCount?: boolean): void; + + /** + * Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT for a duration field. + * Does not require the creation of a GlideDateTime object because the duration field is already a + * GlideDateTime object. + * + * @returns Number of milliseconds since January 1, 1970, 00:00:00 GMT. + * @example + * + * var inc = new GlideRecord('incident'); + * inc.get('17c90efb13418700cc36b1422244b05d'); + * gs.info(inc.calendar_duration.dateNumericValue()); + */ + dateNumericValue(): number; + + /** + * Deletes multiple records that satisfy the query condition. + * + * @example + * + * var gr = new GlideRecord('incident') + * gr.addQuery('active','false'); //to delete all inactive incidents + * gr.deleteMultiple(); + */ + deleteMultiple(): void; + + /** + * Deletes the current record. + * + * @returns True if the record was deleted; false if no record was found to delete. + * @example + * + * var gr = new GlideRecord('incident') + * gr.addQuery('sys_id','99ebb4156fa831005be8883e6b3ee4b9'); //to delete one record + * gr.query(); + * gr.next(); + * gr.deleteRecord(); + */ + deleteRecord(): boolean; + + /** + * Defines a GlideRecord based on the specified expression of 'name = value'. + * + * @param name Column name to match (if two arguments are specified), or sys_id (if one is + * specified) + * @param [value] Value to match. If value is not specified, then the expression used is + * 'sys_id = name'. + * @returns True if one or more matching records was found. False if no matches + * found. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.get('99ebb4156fa831005be8883e6b3ee4b9'); + * gs.info(gr.number); + */ + get(name: string, value?: string): boolean; + + /** + * Returns the dictionary attributes for the specified field. + * + * @param fieldName Field name for which to return the dictionary attributes + * @returns Dictionary attributes + * @example + * + * doit(); + * function doit() { + * var gr = new GlideRecord('sys_user'); + * gr.query("user_name","admin"); + * if (gr.next()) { + * gs.print("we got one"); + * gs.print(gr.location.getAttribute("tree_picker")); + * } + * } + */ + getAttribute(fieldName: string): string; + + /** + * Returns the table's label. + * + * @returns Table's label + */ + getClassDisplayValue(): string; + + /** + * Retrieves the display value for the current record. + * + * @returns The display value for the current record. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.get('sys_id','ef43c6d40a0a0b5700c77f9bf387afe3'); + * gs.info(gr.getDisplayValue()); + */ + getDisplayValue(field?: string): string; + + /** + * Returns the element's descriptor. + * + * @returns Element's descriptor + * @example + * + * var gr = new GlideRecord('incident'); + * var ed = gr.getED(); + * gs.info(ed.getLabel()); + * // Incident + */ + getED(): ScopedElementDescriptor; + + /** + * Retrieves the GlideElement object for the specified field. + * + * @param columnName Name of the column to get the element from. + * @returns The GlideElement for the specified column of the current record. + * @example + * + * var elementName = 'short_description'; + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gr.setValue(elementName, "My DB is not working"); + * gr.insert(); + * gs.info(gr.getElement('short_description')); + */ + getElement(columnName: string): ScopedGlideElement; + + /** + * Returns an array of GlideElements for the current record. + * + * @returns The array of GlideElements for the current record. + */ + getElements(): [ScopedGlideElement]; + + /** + * Retrieves the query condition of the current result set as an encoded query string. + * + * @returns The encoded query as a string. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.addQuery('active', true); + * gr.addQuery('priority', 1); + * gr.query(); + * var encodedQuery = gr.getEncodedQuery(); + * gs.info(encodedQuery); + */ + getEncodedQuery(): string; + + /** + * Returns the field's label. + * + * @returns Field's label + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.getLabel()); + * // Incident + */ + getLabel(): string; + + /** + * Retrieves the last error message. If there is no last error message, null is returned. + * + * @returns The last error message as a string. + * @example + * + * // Setup a data policy where short_description field in incident is mandatory + * var gr = new GlideRecord('incident'); + * gr.insert(); // insert without data in mandatory field + * var errormessage = gr.getLastErrorMessage(); + * gs.info(errormessage); + */ + getLastErrorMessage(): string; + + /** + * Retrieves a link to the current record. + * + * @param noStack If true, the sysparm_stack parameter is not appended to the link. + * The parameter sysparm_stack specifies the page to visit after closing the current link. + * @returns A link to the current record as a string. + * @example + * + * gr = new GlideRecord('incident'); + * gr.addActiveQuery(); + * gr.addQuery("priority", 1); + * gr.query(); + * gr.next() + * gs.info(gs.getProperty('glide.servlet.uri') + gr.getLink(false)); + */ + getLink(noStack: boolean): string; + + /** + * Retrieves the class name for the current record. + * + * @returns The class name. + * @example + * + * var gr = new GlideRecord('incident'); + * var recordClassName = gr.getRecordClassName(); + * gs.info(recordClassName); + */ + getRecordClassName(): string; + + /** + * Retrieves the number of rows in the query result. + * + * @returns The number of rows. + * @example + * + * var gr = new GlideRecord('incident') + * gr.query(); + * gs.info("Records in incident table: " + gr.getRowCount()); + */ + getRowCount(): number; + + /** + * Retrieves the name of the table associated with the GlideRecord. + * + * @returns The table name + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.getTableName()); + */ + getTableName(): string; + + /** + * Gets the primary key of the record, which is usually the sys_id unless otherwise + * specified. + * + * @returns The unique primary key as a String, or null if the key is null. + * @example + * + * var gr = new GlideRecord('kb_knowledge'); + * gr.query(); + * gr.next(); + * var uniqueid = gr.getUniqueValue(); + * gs.info(uniqueid); + */ + getUniqueValue(): string; + + /** + * Retrieves the string value of an underlying element in a field. + * + * @param name The name of the field to get the value from. + * @returns The value of the field. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.orderBy('number'); + * gr.query('active','true'); + * gr.next() ; + * gs.info(gr.getValue('number')); + */ + getValue(name: string): string; + + /** + * Determines if there are any more records in the GlideRecord object. + * + * @returns True if there are more records in the query result set. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.query(); + * if (rec.hasNext()) { + * gs.info("Table is not empty"); + * } + */ + hasNext(): boolean; + + /** + * Creates an empty record suitable for population before an insert. + * + * @example + * + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gr.name='New Incident'; + * gr.description='Incident description'; + * gr.insert(); + */ + initialize(): void; + + /** + * Inserts a new record using the field values that have been set for the current record. + * + * @returns Unique ID of the inserted record, or null if the record is not inserted. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gr.name = 'New Incident'; + * gr.description = 'Incident description'; + * gr.insert(); + */ + insert(): string; + + /** + * Checks to see if the current database action is to be aborted. + * + * @returns True if the current database action is to be aborted + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.isActionAborted()); + */ + isActionAborted(): boolean; + + /** + * Checks if the current record is a new record that has not yet been inserted into the database. + * + * @returns True if the record is new and has not been inserted into the database. + * @example + * + * var gr = new GlideRecord("x_app_table"); + * gr.newRecord(); // create a new record and populate it with default values + * gs.info(gr.isNewRecord()); + */ + isNewRecord(): boolean; + + /** + * Determines if the table exists. + * + * @returns True if table is valid or if record was successfully retrieved. False if table is + * invalid or record was not successfully retrieved. + * @example + * + * var gr = new GlideRecord('incident'); + * gs.info(gr.isValid()); + * var anotherGr = new GlideRecord('wrong_table_name'); + * gs.info(anotherGr.isValid()); + */ + isValid(): boolean; + + /** + * Determines if the specified field is defined in the current table. + * + * @param columnName The name of the the field. + * @returns True if the field is defined for the current table. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gs.info(gr.isValidField("short_description")); + */ + isValidField(columnName: string): boolean; + + /** + * Determines if current record is a valid record. + * + * @returns True if the current record is valid. False if past the end of the record set. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.query(); + * while (rec.next()) { + * gs.info(rec.number + ' exists'); + * } + * gs.info(rec.isValidRecord()); + */ + isValidRecord(): boolean; + + /** + * Creates a new GlideRecord record, sets the default values for the fields, and assigns a unique + * ID to the record. + * + * @example + * + * var gr = new GlideRecord("x_app_table"); + * gr.newRecord(); + * gs.info(gr.isNewRecord()); + */ + newRecord(): void; + + /** + * Moves to the next record in the GlideRecord object. + * + * @returns True if moving to the next record is successful. False if there are no more records in + * the result set. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.query(); + * while (rec.next()) { + * gs.info(rec.number + ' exists'); + * } + */ + next(): boolean; + + /** + * Retrieves the current operation being performed, such as insert, update, or delete. + * + * @returns The current operation. + * @example + * + * // Commonly used in a business rule, returns insert if the current operation is insert + * gs.info("current operation " + current.operation()); + */ + operation(): GlideRecordOperation; + + /** + * Specifies an orderBy column. + * + * @param name The column name used to order the records in this GlideRecord object. + * @example + * + * var queryString = "priority=2"; + * var gr = new GlideRecord('incident'); + * gr.orderBy('short_description'); // Ascending Order + * gr.addEncodedQuery(queryString); + * gr.query(); + * while (gr.next()) { + * gs.info(gr.short_description); + * } + */ + orderBy(name: string): void; + + /** + * Specifies a decending orderBy column. + * + * @param name The column name to be used to order the records in a GlideRecord object. + * @example + * + * var queryString = "priority=2"; + * var gr = new GlideRecord('incident'); + * gr.orderByDesc('short_description'); //Descending Order + * gr.addEncodedQuery(queryString); + * gr.query(); + * while (gr.next()) { + * gs.info(gr.short_description); + * } + */ + orderByDesc(name: string): void; + + /** + * Runs the query against the table based on the filters specified by addQuery, addEncodedQuery, + * etc. + * + * This queries the GlideRecord table as well as any references of the table. Usually this is + * performed without arguments. If name/value pair is specified, "name=value" condition is added + * to the query. + * + * @param field The column name to query on. + * @param value The value to query for. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.query(); + * while (rec.next()) { + * gs.info(rec.number + ' exists'); + * } + */ + query(field?: string, value?: any): void; + + /** + * Sets a flag to indicate if the next database action (insert, update, delete) is to be aborted. + * This is often used in business rules. + * + * @param b True to abort the next action. False if the action is to be allowed. + * @example + * + * // Often used in business rule to check whether the current operation should be aborted. + * if (current.size > 16) { + * current.setAbortAction(true); + * } + */ + setAbortAction(b: boolean): void; + + /** + * Scoped API docs include `setDateNumericValue` but it is not a valid method. + * When called, it throws: + * org.mozilla.javascript.EcmaError: Cannot find function setDateNumericValue in object + * [object GlideRecord]. + */ + // setDateNumericValue(milliseconds: number): void; + + /** + * Sets the limit for number of records are fetched by the GlideRecord query. + * + * @param maxNumRecords The maximum number of records to fetch. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.orderByDesc('sys_created_on'); + * gr.setLimit(10); + * gr.query(); // this retrieves latest 10 incident records created + */ + setLimit(maxNumRecords: number): void; + + /** + * Sets sys_id value for the current record. + * + * @param guid The GUID to be assigned to the current record. + * @example + * + * var gr = new GlideRecord('incident'); + * gr.short_description='The third floor printer is broken'; + * gr.setNewGuidValue('eb4636ca6f6d31005be8883e6b3ee333'); + * gr.insert(); + * gs.info(gr.sys_id); + */ + setNewGuidValue(guid: string): void; + + /** + * Sets the value of the field with the specified name to the specified value. + * + * @param name Name of the field. + * @param value The value to assign to the field. + * @example + * + * var elementName = 'short_description'; + * var gr = new GlideRecord('incident'); + * gr.initialize(); + * gr.setValue(elementName, "My DB is not working"); + * gr.insert(); + */ + setValue(name: string, value: any): void; + + /** + * Enables or disables the running of business rules, script engines, and audit. + * + * @param enable If true (default), enables business rules. If false, disables business + * rules. + * @example + * + * //Enable business rules, scripts engines for x_app_table + * var gr = new GlideRecord("x_app_table"); + * gr.setWorkflow(true); + */ + setWorkflow(enable: boolean): void; + + /** + * Updates the GlideRecord with any changes that have been made. If the record does not already + * exist, it is inserted. + * + * @param [reason] The reason for the update. The reason is displayed in the audit record. + * @returns Unique ID of the new or updated record. Returns null if the update fails. + * @example + * + * var gr = new GlideRecord('incident') + * gr.get('99ebb4156fa831005be8883e6b3ee4b9'); + * gr.short_description='Update the short description'; + * gr.update(); + * gs.info(gr.getElement('short_description')); + */ + update(reason?: string): string; + + /** + * Updates each GlideRecord in the list with any changes that have been made. + * + * @example + * + * // update the state of all active incidents to 4 - "Awaiting User Info" + * var gr = new GlideRecord('incident') + * gr.addQuery('active', true); + * gr.query(); + * gr.setValue('state', 4); + * gr.updateMultiple(); + */ + updateMultiple(): void; + + /** + * Moves to the next record in the GlideRecord. Provides the same functionality as next(), it is + * intended to be used in cases where the GlideRecord has a column named next. + * + * @returns True if there are more records in the query set. + * @example + * + * var rec = new GlideRecord('sys_template'); + * rec.query(); + * while (rec._next()) { + * gs.print(rec.number + ' exists'); + * } + */ + _next(): boolean; + + /** + * Identical to query(). This method is intended to be used on tables where there is a column + * named query, which would interfere with using the query() method. + * + * @param name Column name on which to query + * @param value Value for which to query + * @example + * + * var rec = new GlideRecord('sys_app_module'); + * rec._query(); + * while (rec.next()) { + * gs.print(rec.number + ' exists'); + * } + */ + _query(name?: string, value?: any): void; +} diff --git a/types/servicenow-london/ScopedQueryCondition.d.ts b/types/servicenow-london/ScopedQueryCondition.d.ts new file mode 100644 index 0000000000..2cffd17769 --- /dev/null +++ b/types/servicenow-london/ScopedQueryCondition.d.ts @@ -0,0 +1,72 @@ +interface ScopedQueryCondition { + /** + * Adds an AND condition to the current condition. + * + * @param name The name of a field. + * @param value The value to query on. + * @returns A reference to a GlideQueryConditon that was added to the GlideRecord. + * @example + * var gr = new GlideRecord('incident'); + * var qc = gr.addQuery('category', 'Hardware'); + * qc.addCondition('category', 'Network'); + * gr.addQuery('number','INC0000003'); + * gr.next(); + * gr.number; + * gs.info(gr.getEncodedQuery()); + */ + addCondition(name: string, value: object | string | number): ScopedQueryCondition; + + /** + * Adds an AND condition to the current condition. + * + * @param name The name of a field. + * @param oper The operator for the query. + * If you do not specify an operator, the condition uses an equals operator. + * @param value The value to query on. + * @returns A reference to a GlideQueryConditon that was added to the GlideRecord. + */ + addCondition( + name: string, + oper: QueryOperator, + value: object | string | number + ): ScopedQueryCondition; + + /** + * Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition. + * + * @param name Field name + * @param value The value to query on. + * @returns A reference to a GlideQueryConditon that was added to the GlideRecord. + */ + addOrCondition(name: string, value: object | string | number): ScopedQueryCondition; + + /** + * Appends a 2-or-3 parameter OR condition to an existing GlideQueryCondition. + * + * @param name Field name + * @param oper Query operator. + * The available values are dependent on the data type of the value parameter. + * + * Numbers: + * - = + * - != + * - > + * - >= + * - < + * - <= + * + * Strings (must be in upper case): + * - = + * - != + * - IN + * - NOT IN + * - STARTSWITH + * - ENDSWITH + * - CONTAINS + * - DOES NOT CONTAIN + * - INSTANCEOF + * @param value The value to query on. + * @returns A reference to a GlideQueryConditon that was added to the GlideRecord. + */ + addOrCondition(name: string, oper: QueryOperator, value: any): ScopedQueryCondition; +} diff --git a/types/servicenow-london/Workflow.d.ts b/types/servicenow-london/Workflow.d.ts new file mode 100644 index 0000000000..05b1f9e3dd --- /dev/null +++ b/types/servicenow-london/Workflow.d.ts @@ -0,0 +1,97 @@ +declare namespace global { + class Workflow { + constructor(); + broadcastEvent(contextId: string, eventName: string): void; + cancel(record: ScopedGlideRecord): void; + cancelContext(context: ScopedGlideRecord): void; + deleteWorkflow(current: ScopedGlideRecord): void; + fireEvent(eventRecord: ScopedGlideRecord, eventName: string): void; + fireEventById(eventRecordId: string, eventName: string): void; + getContexts(record: ScopedGlideRecord): ScopedGlideRecord; + getEstimatedDeliveryTime(workflowId: string): string; + getEstimatedDeliveryTimeFromWFVersion(wfVersion: ScopedGlideRecord): string; + + /** + * Get the return value set by activity "Return Value" + * + * @param context wf_context GlideRecord of the context from which you want the return value + * @return The value set by activity "Return Value" in the workflow + */ + getReturnValue(context: ScopedGlideRecord): any; + getRunningFlows(record: ScopedGlideRecord): ScopedGlideRecord; + getVersion(workflowId: string): ScopedGlideRecord; + getVersionFromName(workflowName: string): ScopedGlideElement; + getWorkflowFromName(workflowName: string): string; + hasWorkflow(record: ScopedGlideRecord): boolean; + restartWorkflow(record: ScopedGlideRecord, maintainStateFlag?: boolean): void; + + /** + * Run all flows attached to a current GlideRecord. + * + * Calling this method on a current will not implicitly update the current. If the workflow + * modifies the input current to this method, it is up to the caller to call + * current.update() to persist these changes. + * + * @param record A GlideRecord that holds the current record + * @param operation A String that holds the operation such as "update", "insert", or perhaps + * "timer" or some other user defined value. + */ + runFlows(record: ScopedGlideRecord, operation: GlideRecordOperation): void; + + /** + * Start a workflow. Internal logic will determine which workflow version should be run. The + * workflow version to run is either the one checked out to the current user, or the + * published workflow version. Calling this method on a current will not implicitly update + * the current. If the workflow modifies the input current to this method, it is up to the + * caller to call current.update() to persist these changes. + * + * @param workflowId The sys_id of the workflow from the wf_workflow table + * @param current The GlideRecord of the current record to be operated on by the workflow + * @param operation The String operation for this workflow - not used + * @param vars JavaScript object of workflow inputs. The key is the variable name, the value + * is the variable value. + * @returns The GlideRecord of the wf_context of the running workflow. Do not modify this + * returned GlideRecord. + */ + startFlow( + workflowId: string, + current: ScopedGlideRecord | null, + operation: GlideRecordOperation, + vars?: object + ): string; + + /** + * An intermediate method used to start a workflow from the green "run" button on the + * Graphical Workflow Editor. This should not be used by SNC script writers. + * + * @param context GlideRecord on wf_context of the context to start the Workflow engine on + * @param operation The String event for processing + */ + startFlowFromContextInsert( + context: ScopedGlideRecord, + operation: GlideRecordOperation + ): void; + + /** + * An intermediate method used to start a workflow with preloaded values for SLA Timer + * activity. This should not be used by SNC script writers + * + * @param workflowId The sys_id of a record in table wf_workflow for the workflow to run + * @param retroactiveMSecs Integer value of seconds to start the workflow on. This is used + * by SLA Timer activity + * @param current The GlideRecord of the current record + * @param operation The String event for processing - not used. + * @param vars JavaScript object or Java HashMap of workflow inputs. The key is the variable + * name, the value is the variable value + * @param withSchedule Boolean value to indicate if a schedule should be used + */ + startFlowRetroactive( + workflowID: string, + retroactiveMSecs: number, + current: ScopedGlideRecord, + operation: GlideRecordOperation, + vars?: object, + withSchedule?: any + ): ScopedGlideRecord; + } +} diff --git a/types/servicenow-london/XMLDocument2.d.ts b/types/servicenow-london/XMLDocument2.d.ts new file mode 100644 index 0000000000..d52b057a72 --- /dev/null +++ b/types/servicenow-london/XMLDocument2.d.ts @@ -0,0 +1,13 @@ +declare class XMLDocument2 { + constructor(); + createElement(name: string): XMLNode; + createElementWithTextValue(name: string, value: string): XMLNode; + getDocumentElement(): XMLNode; + getFirstNode(xpath: string): XMLNode; + getNextNode(prev: object): XMLNode; + getNode(xpath: string): XMLNode; + getNodeText(xpath: string): string; + parseXML(xmlDoc: string): void; + setCurrentElement(element: XMLNode): void; + toString(): string; +} diff --git a/types/servicenow-london/XMLNode.d.ts b/types/servicenow-london/XMLNode.d.ts new file mode 100644 index 0000000000..2ad525b49b --- /dev/null +++ b/types/servicenow-london/XMLNode.d.ts @@ -0,0 +1,11 @@ +interface XMLNode { + getLastChild(): XMLNode; + getFirstChild(): XMLNode; + getNodeValue(): string; + getNodeName(): string; + hasAttribute(name: string): boolean; + getAttribute(attribute: string): string; + getChildNodeIterator(): XMLNodeIterator; + getTextContent(): string; + toString(): string; +} diff --git a/types/servicenow-london/XMLNodeIterator.d.ts b/types/servicenow-london/XMLNodeIterator.d.ts new file mode 100644 index 0000000000..4e404ec199 --- /dev/null +++ b/types/servicenow-london/XMLNodeIterator.d.ts @@ -0,0 +1,4 @@ +interface XMLNodeIterator { + hasNext(): boolean; + next(): XMLNode; +} diff --git a/types/servicenow-london/index.d.ts b/types/servicenow-london/index.d.ts new file mode 100644 index 0000000000..1a236a1708 --- /dev/null +++ b/types/servicenow-london/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for non-npm package servicenow-london 1.0 +// Project: https://developer.servicenow.com/app.do#!/api_doc?v=london +// Definitions by: John Caruso +// Bryce Godfrey +// Garrett Griffin +// Erik Myrold +// Tim Woodruff +// Anim Yeboah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +declare const GlideRecord: ScopedGlideRecord; +declare const GlideRecordSecure: ScopedGlideRecord; +declare const RP: RenderProperties; +declare const current: ScopedGlideRecord; +declare const email: GlideEmailOutbound; +declare const g_processor: GlideScriptedProcessor; +declare const g_request: GlideServletRequest; +declare const g_response: GlideServletResponse; +declare const gs: GlideSystem; +declare const previous: ScopedGlideRecord; diff --git a/types/servicenow-london/test/Class.ts b/types/servicenow-london/test/Class.ts new file mode 100644 index 0000000000..f6d1c9f2b7 --- /dev/null +++ b/types/servicenow-london/test/Class.ts @@ -0,0 +1,11 @@ +var NewInclude = Class.create(); + +NewInclude.prototype = { + initialize: function() {}, + + myFunction: function() { + //Put function code here + }, + + type: 'NewInclude' +}; diff --git a/types/servicenow-london/test/GlideDBFunctionBuilder.ts b/types/servicenow-london/test/GlideDBFunctionBuilder.ts new file mode 100644 index 0000000000..0fc4b980e1 --- /dev/null +++ b/types/servicenow-london/test/GlideDBFunctionBuilder.ts @@ -0,0 +1,75 @@ +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myAddingFunction = functionBuilder.add(); + myAddingFunction = functionBuilder.field('order'); + myAddingFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myAddingFunction = functionBuilder.add(); + myAddingFunction = functionBuilder.field('order'); + myAddingFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); + gs.info(func); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myConcatFunction = functionBuilder.concat(); + myConcatFunction = functionBuilder.field('short_description'); + myConcatFunction = functionBuilder.field('caller_id.name'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myDateDiffFunction = functionBuilder.datediff(); + myDateDiffFunction = functionBuilder.field('sys_updated_on'); + myDateDiffFunction = functionBuilder.field('opened_at'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var dayOfWeekFunction = functionBuilder.dayofweek(); + dayOfWeekFunction = functionBuilder.field('opened_at'); + dayOfWeekFunction = functionBuilder.constant('2'); + var func = functionBuilder.build(); + + var gr = new GlideRecord('incident'); + gr.addFunction(func); + gr.query(); + while (gr.next()) gs.info(gr.getValue(func)); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myDivideFunction = functionBuilder.divide(); + myDivideFunction = functionBuilder.field('order'); + myDivideFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myAddingFunction = functionBuilder.add(); + myAddingFunction = functionBuilder.field('order'); + myAddingFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myLengthFunction = functionBuilder.length(); + myLengthFunction = functionBuilder.field('short_description'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myMultiplyFunction = functionBuilder.multiply(); + myMultiplyFunction = functionBuilder.field('order'); + myMultiplyFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var mySubtractFunction = functionBuilder.subtract(); + mySubtractFunction = functionBuilder.field('order'); + mySubtractFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); +})(); diff --git a/types/servicenow-london/test/GlideDate.ts b/types/servicenow-london/test/GlideDate.ts new file mode 100644 index 0000000000..1a4c2fd086 --- /dev/null +++ b/types/servicenow-london/test/GlideDate.ts @@ -0,0 +1,18 @@ +(function() { + var gd = new GlideDate(); + gs.info(gd.getByFormat('dd-MM-yyyy')); + gs.info(gd.getDayOfMonthNoTZ()); + gs.info(gd.getDisplayValue()); + gs.info(gd.getDisplayValueInternal()); + gs.info(gd.getMonthNoTZ()); + gs.info(gd.getValue()); + gs.info(gd.getYearNoTZ()); + gd.setDisplayValue('2011-01-01'); + gd.setValue('2015-01-01'); + var sgd1 = new GlideDate(); + sgd1.setDisplayValue('2014-07-18'); + var sgd2 = new GlideDate(); + sgd2.setDisplayValue('2014-07-19'); + var duration = GlideDate.subtract(sgd1, sgd2); + gs.info(duration.getDisplayValue()); +})(); diff --git a/types/servicenow-london/test/GlideDateTime.ts b/types/servicenow-london/test/GlideDateTime.ts new file mode 100644 index 0000000000..e3396f268d --- /dev/null +++ b/types/servicenow-london/test/GlideDateTime.ts @@ -0,0 +1,100 @@ +(function() { + var gdt = new GlideDateTime('2011-08-31 08:00:00'); + var gtime1 = new GlideTime(); + gtime1.setValue('00:00:20'); + gdt.add(gtime1); + var gtime2 = gdt.getTime(); + gs.info(gtime2.getByFormat('hh:mm:ss')); + gdt.add(10); + var start = new GlideDateTime('2011-01-01 12:00:00'); + var end = new GlideDateTime(start); + gdt.addDaysLocalTime(-1); + gdt.addDaysUTC(-1); + gdt.addMonthsLocalTime(2); + gdt.addMonthsUTC(2); + gdt.addSeconds(1000); + gdt.addWeeksLocalTime(-1); + gdt.addWeeksUTC(-1); + gdt.addYearsLocalTime(1); + gdt.addYearsUTC(1); + var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + gs.info(gdt1.after(gdt2)); + gs.info(gdt1.before(gdt2)); + var initDate = new GlideDateTime('2011-08-01 12:00:00'); + var compDate1 = new GlideDateTime('2011-08-01 12:00:00'); + var compDate2 = new GlideDateTime('2011-07-31 12:00:00'); + var compDate3 = new GlideDateTime('2011-08-04 16:00:00'); + gs.info(initDate.compareTo(compDate1)); // Equals (0) + gs.info(initDate.compareTo(compDate2)); // initDate is after compDate2 (1) + gs.info(initDate.compareTo(compDate3)); // initDate is before compDate3 (-1) + gs.info(gdt.equals('2011-09-30 00:12:01')); + gs.info(gdt.getDate()); + gs.info(gdt.getValue()); + gs.info(gdt.getDayOfMonthLocalTime()); + gs.info(gdt.getDayOfMonthUTC()); + gs.info(gdt.getDayOfWeekLocalTime()); + gs.info(gdt.getDayOfWeekLocalTime()); + gs.info(gdt.getDaysInMonthLocalTime()); + gs.info(gdt.getDaysInMonthUTC()); + gs.info(gdt.getDisplayValue()); + gs.info(gdt.getDisplayValueInternal()); //uses current user session time zone (US/Pacific) + gs.info(gdt.getDSTOffset()); //uses current user session time zone (US/Pacific) + gdt.setDisplayValue('2011-aa-01 00:00:00'); + gs.info(gdt.getErrorMsg()); // Could not parse DateTime: 2011-aa-01 00:00:00 + gs.info(gdt.getLocalDate()); + var gt = gdt.getLocalTime(); + gs.info('local time is ' + gt.getByFormat('hh:mm:ss')); + gs.info(gdt.getMonthLocalTime()); + gs.info(gdt.getMonthUTC()); + gs.info(gdt.getNumericValue()); + var gt = gdt.getTime(); + gs.info(gt.getByFormat('hh:mm:ss')); + gdt.getLocalTime(); // PST local time + gs.info(gdt.getTZOffset()); + gs.info(gdt.getValue()); + gs.info(gdt.getWeekOfYearLocalTime()); + gs.info(gdt.getWeekOfYearUTC()); + gs.info(gdt.getYearLocalTime()); + gs.info(gdt.getYearUTC()); + gs.info(gdt.hasDate()); + gs.info(gdt.isDST()); //true + gdt.setDisplayValue('2011-aa-01 00:00:00'); + gs.info(gdt.isValid()); + var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); + var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); + gs.info(gdt1.onOrAfter(gdt2)); + gs.info(gdt1.onOrBefore(gdt2)); + gdt.setDayOfMonthLocalTime(9); + gs.info(gdt.getDayOfMonthLocalTime()); + gdt.setDayOfMonthUTC(9); + gs.info(gdt.getDayOfMonthUTC()); + gdt.setDisplayValue('2014-01-01 12:00:00'); + gdt.setDisplayValue('20-5-2011 12:00:00', 'dd-MM-yyyy HH:mm:ss'); + gdt.setDisplayValueInternal('2014-01-01 12:00:00'); + var dt1 = new GlideDateTime('2011-01-01 12:00:00'); + var dt2 = new GlideDateTime('2011-02-02 08:00:00'); + dt1.setGlideDateTime(dt2); + gdt.setMonthLocalTime(1); + gs.info(gdt.getMonthLocalTime()); + gdt.setMonthUTC(1); + gs.info(gdt.getMonthUTC()); + gdt.setValue('2011-02-02 08:00:00'); // value set = 2011-02-02 08:00:00 + gdt.setValueUTC('15-02-2011 08:00:00', 'dd-MM-yyyy HH:mm:ss'); + gdt.setYearLocalTime(2013); + gs.info(gdt.getYearLocalTime()); + gdt.setYearUTC(2013); + gs.info(gdt.getYearUTC()); + var gdt1 = new GlideDateTime('2011-08-28 09:00:00'); + var gdt2 = new GlideDateTime('2011-08-31 08:00:00'); + var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2 + gs.info(dur.getDisplayValue()); + var gtime1 = new GlideTime(); + gtime1.setValue('00:00:20'); + gdt.subtract(gtime1); + var gtime2 = gdt.getTime(); + gs.info(gtime2.getByFormat('hh:mm:ss')); + var gdt = new GlideDateTime('2011-12-07 08:00:00'); + gdt.subtract(1000); + gs.info(gdt.toString()); +})(); diff --git a/types/servicenow-london/test/GlideDuration.ts b/types/servicenow-london/test/GlideDuration.ts new file mode 100644 index 0000000000..f217d74e74 --- /dev/null +++ b/types/servicenow-london/test/GlideDuration.ts @@ -0,0 +1,46 @@ +(function() { + var duration = new GlideDuration('3 12:00:00'); + var duration2 = new GlideDuration('3:00:00'); + var answer = duration.add(duration2); + gs.info(answer.getDisplayValue()); +})(); +(function() { + var dur = new GlideDuration('3 22:00:00'); + gs.info(dur.getByFormat('HH:mm')); +})(); +(function() { + var dur = new GlideDuration('3 12:00:00'); + gs.info(dur.getDayPart()); +})(); +(function() { + var dur = new GlideDuration('3 12:00:00'); + gs.info(dur.getDisplayValue()); +})(); +(function() { + var dur = new GlideDuration('3 12:00:00'); + gs.info(dur.getDurationValue()); +})(); +(function() { + var dur = new GlideDuration('3 11:00:00'); + gs.info(dur.getRoundedDayPart()); +})(); +(function() { + var dur = new GlideDuration('3 12:00:00'); + gs.info(dur.getValue()); +})(); +(function() { + var dur = new GlideDuration(); + dur.setDisplayValue('3 08:00:00'); + gs.info(dur.getDisplayValue()); +})(); +(function() { + var dur = new GlideDuration(); + dur.setValue('1970-01-05 08:00:00'); // sets internal DateTime value. The String will be parsed into a GlideDateTime object. + gs.info(dur.getDisplayValue()); +})(); +(function() { + var duration = new GlideDuration('3 12:00:00'); + var duration2 = new GlideDuration('3:00:00'); + var answer = duration.subtract(duration2); + gs.info(answer.getDisplayValue()); +})(); diff --git a/types/servicenow-london/test/GlideEmailOutbound.ts b/types/servicenow-london/test/GlideEmailOutbound.ts new file mode 100644 index 0000000000..969e16255f --- /dev/null +++ b/types/servicenow-london/test/GlideEmailOutbound.ts @@ -0,0 +1,21 @@ +(function() { + email.addAddress('cc', 'joe.employee@something.com'); +})(); +(function() { + email.addAddress('bcc', 'joe.employee@something.com', 'dudley rocks'); +})(); +(function() { + var watermark = email.getWatermark(); +})(); +(function() { + email.setBody('Dear Sir, ...'); +})(); +(function() { + email.setFrom('joe.employee@something.com'); +})(); +(function() { + email.setReplyTo('joe.employee@something.com'); +})(); +(function() { + email.setSubject('Important Issues to discuss'); +})(); diff --git a/types/servicenow-london/test/GlideFilter.ts b/types/servicenow-london/test/GlideFilter.ts new file mode 100644 index 0000000000..ff0348c71e --- /dev/null +++ b/types/servicenow-london/test/GlideFilter.ts @@ -0,0 +1,10 @@ +(function() { + var rec = new GlideRecord('incident'); + rec.query(); + var bool = true; + + while (rec.next()) { + bool = GlideFilter.checkRecord(rec, 'active=true'); + gs.info('number ' + rec.number + ' is ' + bool); + } +})(); diff --git a/types/servicenow-london/test/GlideLocale.ts b/types/servicenow-london/test/GlideLocale.ts new file mode 100644 index 0000000000..831d035919 --- /dev/null +++ b/types/servicenow-london/test/GlideLocale.ts @@ -0,0 +1,15 @@ +(function() { + var locale = GlideLocale.get(); +})(); +(function() { + var locale = GlideLocale.get(); + var decimalSeparator = locale.getDecimalSeparator(); + gs.info('The decimal separator is ' + decimalSeparator); + // The decimal separator is . +})(); +(function() { + var locale = GlideLocale.get(); + var groupingSeparator = locale.getGroupingSeparator(); + gs.info('The grouping separator is ' + groupingSeparator); + // The grouping separator is , +})(); diff --git a/types/servicenow-london/test/GlidePluginManager.ts b/types/servicenow-london/test/GlidePluginManager.ts new file mode 100644 index 0000000000..ca040d31b2 --- /dev/null +++ b/types/servicenow-london/test/GlidePluginManager.ts @@ -0,0 +1,18 @@ +(function() { + var gr = new GlideRecord('sys_plugins'); + var queryString = 'active=0^ORactive=1'; + gr.addEncodedQuery(queryString); + gr.query(); + var pMgr = new GlidePluginManager(); + + while (gr.next()) { + var name = gr.getValue('name'); + var pID = gr.getValue('source'); + var isActive = pMgr.isActive(pID); + if (isActive) gs.info('The plugin ' + name + ' is active'); + } + // The plugin Country Lookup Data is active + // The plugin Database Replication is active + // The plugin REST API Provider is active + // The plugin Ten Cool Things is active ... +})(); diff --git a/types/servicenow-london/test/GlideSchedule.ts b/types/servicenow-london/test/GlideSchedule.ts new file mode 100644 index 0000000000..ada8aeaf6d --- /dev/null +++ b/types/servicenow-london/test/GlideSchedule.ts @@ -0,0 +1,62 @@ +(function() { + var startDate = new GlideDateTime('2014-01-02'); + var days = 2; + var dur = new GlideDuration(60 * 60 * 24 * 1000 * days); + var schedule = new GlideSchedule(); + var end = schedule.add(startDate, dur); + gs.info(end); +})(); +(function() { + var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', 'US/Pacific'); +})(); +(function() { + var startDate = new GlideDateTime('2014-10-16 02:00:00'); + var endDate = new GlideDateTime('2014-10-18 04:00:00'); + var schedule = new GlideSchedule(); + + schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule + var duration = schedule.duration(startDate, endDate); + gs.info(duration.getDurationValue()); // gets the elapsed time in schedule +})(); +(function() { + var sys_id = '04e664654a36232701a2247dcd8fc4cf'; // sys_id for "Application" schedule record + var sched = new GlideSchedule(sys_id); + gs.info(sched.getName()); +})(); +(function() { + var g = new GlideRecord('cmn_schedule'); + g.addQuery('type', 'blackout'); + g.query(); + if (g.next()) { + var sched = new GlideSchedule(g.sys_id); + var d = new GlideDateTime(); + d.setDisplayValue('2007-09-18 12:00:00'); + if (sched.isInSchedule(d)) gs.info('Is in the schedule'); + else gs.info('Is NOT in the schedule'); + } +})(); +(function() { + var g = new GlideRecord('cmn_schedule'); + g.addQuery('type', 'blackout'); + g.query(); + if (g.next()) { + var sched = new GlideSchedule(g.sys_id); + var d = new GlideDateTime(); + d.setDisplayValue('2007-09-18 12:00:00'); + if (sched.isValid()) gs.info('Is valid'); + else gs.info('Is not valid'); + } +})(); +(function() { + var x = new GlideSchedule(); + x.load('08fcd0830a0a0b2600079f56b1adb9ae'); +})(); +(function() { + var schedule = new GlideSchedule(); + schedule.setTimeZone('US/Pacific'); +})(); +(function() { + var startDate = new GlideDateTime('2014-10-25 08:00:00'); + var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', 'UTC'); + gs.info(glideSchedule.whenNext(startDate)); +})(); diff --git a/types/servicenow-london/test/GlideScopedEvaluator.ts b/types/servicenow-london/test/GlideScopedEvaluator.ts new file mode 100644 index 0000000000..4a3745ee11 --- /dev/null +++ b/types/servicenow-london/test/GlideScopedEvaluator.ts @@ -0,0 +1,34 @@ +(function() { + // For this example, we created a table: "x_app_table" + // with two columns: "short_description", "test_script" + // "test_script" will store the script to be evaluated by GlideScopedEvaluator. + var gr = new GlideRecord('x_app_table'); + gr.short_description = 'Testing GlideScopedEvaluator'; + gr.test_script = "gs.getUser().getName() + ' says ' + greeting; "; + gr.insert(); + + // setup variables to be used by the script + var vars = { greeting: 'hello' }; + + //Evaluate the script from the field + var evaluator = new GlideScopedEvaluator(); + gs.info(evaluator.evaluateScript(gr, 'test_script', vars)); + // ${user_name} says hello +})(); +(function() { + //setting up a record that contains the script to be executed. + var gr = new GlideRecord('x_app_table'); + gr.short_description = 'Calculate Addition'; + gr.test_script = 'result = x + y'; + gr.insert(); + + var evaluator = new GlideScopedEvaluator(); + evaluator.putVariable('x', 100); + evaluator.putVariable('y', 200); + evaluator.putVariable('result', null); + + // Now retrieve the result + evaluator.evaluateScript(gr, 'test_script', null); + gs.info(evaluator.getVariable('result')); + // 300 +})(); diff --git a/types/servicenow-london/test/GlideScriptedProcessor.ts b/types/servicenow-london/test/GlideScriptedProcessor.ts new file mode 100644 index 0000000000..470458074c --- /dev/null +++ b/types/servicenow-london/test/GlideScriptedProcessor.ts @@ -0,0 +1,16 @@ +(function() { + //Do whatever processing you need and redirect to the homepage + g_processor.redirect('/navpage.do'); +})(); +(function() { + var map = { key1: 'value1', key2: 'value2' }; + g_processor.writeJSON(map); +})(); +(function() { + var name = g_request.getParameter('name'); + g_processor.writeOutput('text/plain', 'Hello ' + name); +})(); +(function() { + var name = g_request.getParameter('name'); + g_processor.writeOutput('Hello ' + name); +})(); diff --git a/types/servicenow-london/test/GlideSecureRandomUtil.ts b/types/servicenow-london/test/GlideSecureRandomUtil.ts new file mode 100644 index 0000000000..249f502af7 --- /dev/null +++ b/types/servicenow-london/test/GlideSecureRandomUtil.ts @@ -0,0 +1,12 @@ +(function() { + gs.info(GlideSecureRandomUtil.getSecureRandomInt()); +})(); +(function() { + gs.info(GlideSecureRandomUtil.getSecureRandomIntBound(100)); +})(); +(function() { + gs.info(GlideSecureRandomUtil.getSecureRandomLong()); +})(); +(function() { + gs.info(GlideSecureRandomUtil.getSecureRandomString(12)); +})(); diff --git a/types/servicenow-london/test/GlideServletRequest.ts b/types/servicenow-london/test/GlideServletRequest.ts new file mode 100644 index 0000000000..0eae56fd0c --- /dev/null +++ b/types/servicenow-london/test/GlideServletRequest.ts @@ -0,0 +1,26 @@ +(function() { + var contentType = g_request.getContentType(); +})(); +(function() { + var headerValue = g_request.getHeader('host'); + // demonightlyus.service-now.com +})(); +(function() { + var headerList = g_request.getHeaderNames(); + // host,connection,cache-control,authorization,accept,user-agent,accept-encoding, + // accept-language, cookie,x-forwarded-proto,x-forwarded-host,x-forwarded-for +})(); +(function() { + var headerValue = g_request.getHeaders('host'); + // demonightlyus.service-now.com +})(); +(function() { + var name = g_request.getParameter('x_snc_custom_x_snc_name'); +})(); +(function() { + var paramList = g_request.getParameterNames(); +})(); +(function() { + var daString = g_request.getQueryString(); + g_processor.writeOutput('The query string is: ' + daString); +})(); diff --git a/types/servicenow-london/test/GlideServletResponse.ts b/types/servicenow-london/test/GlideServletResponse.ts new file mode 100644 index 0000000000..c0cfc5a082 --- /dev/null +++ b/types/servicenow-london/test/GlideServletResponse.ts @@ -0,0 +1,10 @@ +(function() { + g_response.setContentType('text/html;charset=UTF-8'); +})(); +(function() { + g_response.setHeader('host', 'demonightlyus.service-now.com'); +})(); +(function() { + // set the status to okay + g_response.setStatus(200); +})(); diff --git a/types/servicenow-london/test/GlideSession.ts b/types/servicenow-london/test/GlideSession.ts new file mode 100644 index 0000000000..fd702606b3 --- /dev/null +++ b/types/servicenow-london/test/GlideSession.ts @@ -0,0 +1,64 @@ +(function() { + var session = gs.getSession(); + session.putClientData('test1', 'Harry'); + var clientData = session.getClientData('test1'); + gs.info(clientData); + // Harry +})(); +(function() { + var session = gs.getSession(); + var addr = session.getClientIP(); + gs.info(addr); +})(); +(function() { + var session = gs.getSession(); + var appID = session.getCurrentApplicationId(); + gs.info(appID); + // ce05b9f32b840200c5244f74b4da1501 +})(); +(function() { + var session = gs.getSession(); + var language = session.getLanguage(); + gs.info(language); + // en +})(); +(function() { + var session = gs.getSession(); + var token = session.getSessionToken(); + gs.info(token); + // 4284b5372b840200c5244f74b4da15f2c3476cf7fcb6572afa4ef9d5e6d307a5fd9e1da7 +})(); +(function() { + var session = gs.getSession(); + var zoneName = session.getTimeZoneName(); + gs.info(zoneName); + // US/Pacific +})(); +(function() { + var session = gs.getSession(); + var URL = session.getUrlOnStack(); + gs.info(URL); + // sys_app.do?sys_id=ce05b9f32b840200c5244f74b4da1501&sysparm_goto_url=sys_app.do + // %3Fsys_id%3Dce05b9f32b840200c5244f74b4da1501 +})(); +(function() { + var isImpersonator = gs.getSession().isImpersonating(); + gs.info(isImpersonator); +})(); +(function() { + var interActive = gs.getSession().isInteractive(); + gs.info(interActive); +})(); +(function() { + var session = gs.getSession(); + var loggedIn = session.isLoggedIn(); + gs.info(loggedIn); + // true +})(); +(function() { + var session = gs.getSession(); + session.putClientData('test1', 'Harry'); + var clientData = session.getClientData('test1'); + gs.info(clientData); + // Harry +})(); diff --git a/types/servicenow-london/test/GlideStringUtil.ts b/types/servicenow-london/test/GlideStringUtil.ts new file mode 100644 index 0000000000..1cf7a3ab6b --- /dev/null +++ b/types/servicenow-london/test/GlideStringUtil.ts @@ -0,0 +1,85 @@ +(function() { + var filename = '../../../../../../etc/passwd'; + var cleanFilename = GlideStringUtil.dotToUnderBar(filename); + gs.info(cleanFilename); + // __/__/__/__/__/__/etc/passwd +})(); +(function() { + var mystring = "let's escape some quotes"; + var escapeQuote = GlideStringUtil.escapeAllQuotes(mystring); + gs.info(escapeQuote); + // lets escape some quotes +})(); +(function() { + var mystring = ' string \n to escape'; + var escapedString = GlideStringUtil.escapeForHomePage(mystring); + gs.info(escapedString); + // %3ctest%3e string \n to escape +})(); +(function() { + var mydata = '"<>&'; + mydata = GlideStringUtil.escapeHTML(mydata); + gs.info(mydata); + // "<>& +})(); +(function() { + var mystring = 'test \x09 non \x00 printable \x07 chars'; + var escapedString = GlideStringUtil.escapeNonPrintable(mystring); + gs.info(escapedString); + // test \t non \u0000 printable \u0007 chars +})(); +(function() { + var myquery = 'test^Test'; + var escapedQuery = GlideStringUtil.escapeQueryTermSeparator(myquery); + gs.info(escapedQuery); + // test^^Test +})(); +(function() { + var mystring = "let's try escapeTicks"; + var escaped = GlideStringUtil.escapeTicks(mystring); + gs.info(escaped); + // let\'s try escapeTicks +})(); +(function() { + var mydata = '&'; + var htmlvalue = GlideStringUtil.getHTMLValue(mydata); + gs.info(htmlvalue); + // & +})(); +(function() { + var mystring = '123 test 456 String 789 cleaning'; + var onlyNumeric = GlideStringUtil.getNumeric(mystring); + gs.info(onlyNumeric); + // 123456789 +})(); +(function() { + // (adding a "*" to corrupt the base64 format) + var base64 = 'GethdTYehdtshetB*'; + var isValid = GlideStringUtil.isBase64(base64); + gs.info(isValid); + // false +})(); +(function() { + var sysID = '62826bf03710200044e0bfc8bcbe5df1'; + var isElig = GlideStringUtil.isEligibleSysID(sysID); + gs.info(isElig); + // true +})(); +(function() { + var mystring = 'new line break \n, this is after the break'; + var replaceNewLine = GlideStringUtil.newLinesToBreaks(mystring); + gs.info(replaceNewLine); + // new line break
, this is after the break +})(); +(function() { + var mystring = 'test with \n (new line) and \t (tabulation)'; + var normalizedString = GlideStringUtil.normalizeWhitespace(mystring); + gs.info(normalizedString); + // test with (new line) and (tabulation) +})(); +(function() { + var mydata = '"<>&'; + var unescaped = GlideStringUtil.unescapeHTML(mydata); + gs.info(unescaped); + // "<>& +})(); diff --git a/types/servicenow-london/test/GlideSysAttachment.ts b/types/servicenow-london/test/GlideSysAttachment.ts new file mode 100644 index 0000000000..0ffdd02fcb --- /dev/null +++ b/types/servicenow-london/test/GlideSysAttachment.ts @@ -0,0 +1 @@ +// TODO \ No newline at end of file diff --git a/types/servicenow-london/test/GlideSystem.ts b/types/servicenow-london/test/GlideSystem.ts new file mode 100644 index 0000000000..0458978982 --- /dev/null +++ b/types/servicenow-london/test/GlideSystem.ts @@ -0,0 +1,211 @@ +(function() { + gs.addErrorMessage('Invalid account'); +})(); +(function() { + if (!current.u_date1.nil() && !current.u_date2.nil()) { + var start = current.u_date1.getGlideObject().getNumericValue(); + var end = current.u_date2.getGlideObject().getNumericValue(); + if (start > end) { + gs.addInfoMessage('start must be before end'); + current.u_date1.setError('start must be before end'); + current.setAbortAction(true); + } + } +})(); +(function() { + function contractNoticeDue() { + var gr = new GlideRecord('contract'); + gr.addQuery('u_contract_status', 'Active'); + gr.query(); + while (gr.next()) { + if (gr.u_termination_date <= gs.daysAgo(-90) && gr.u_contract_duration == 'Long') { + gr.u_contract_status = 'In review'; + } else if ( + gr.u_termination_date <= gs.daysAgo(-50) && + gr.u_contract_duration == 'Medium' + ) { + gr.u_contract_status = 'In review'; + } else if ( + gr.u_termination_date <= gs.daysAgo(-10) && + gr.u_contract_duration == 'Short' + ) { + gr.u_contract_status = 'In review'; + } + } + gr.update(); + } +})(); +(function() { + var gr = new GlideRecord('sysapproval_approver'); + gr.addQuery('state', 'requested'); + gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(5)); + gr.query(); +})(); +(function() { + gs.debug('This is a debug message'); + var myFirstName = 'Abel'; + var myLastName = 'Tuter'; + gs.debug('This is a debug message from {0}.{1}', myFirstName, myLastName); +})(); +(function() { + gs.error('This is an error message'); + var myFirstName = 'Abel'; + var myLastName = 'Tuter'; + gs.error('This is an error message from {0}.{1}', myFirstName, myLastName); +})(); +(function() { + if (current.operation() != 'insert' && current.comments.changes()) { + gs.eventQueue('incident.commented', current, gs.getUserID(), gs.getUserName()); + } +})(); +(function() { + var personalId = gs.generateGUID(); + gs.info(personalId); + // af770511ff013100e04bfffffffffff6 +})(); +(function() { + return gs.getCallerScopeName(); +})(); +(function() { + var verStr = gs.getCssCacheVersionString(); + gs.info(verStr); + // _d82979516f0171005be8883e6b3ee4cf&theme= +})(); +(function() { + var currentId = gs.getCurrentApplicationId(); + gs.info(currentId); + // 04936cb16f30b1005be8883e6b3ee4e0 +})(); +(function() { + var currentScope = gs.getCurrentScopeName(); + gs.info(currentScope); +})(); +(function() { + var myMessage = gs.getEscapedMessage('Hello {0}', ['mom']); +})(); +(function() { + var attachment_link = gs.getProperty('glide.servlet.uri'); + gs.info(attachment_link); + // https://instance.service-now.com/ +})(); +(function() { + if (!gs.hasRole('admin') && !gs.hasRole('user_admin') && gs.getSession().isInteractive()) { + current.addQuery('active', 'true'); + } +})(); +(function() { + var myUserObject = gs.getSessionID(); + gs.info(myUserObject); +})(); +(function() { + gs.info(gs.getTimeZoneName()); +})(); +(function() { + gs.info(gs.getUrlOnStack()); +})(); +(function() { + var myUserObject = gs.getUser(); +})(); +(function() { + gs.info(gs.getUserDisplayName()); +})(); +(function() { + gs.info(gs.getUserID()); +})(); +(function() { + gs.info(gs.getUserName()); +})(); +(function() { + if (!gs.hasRole('admin') && !gs.hasRole('groups_admin') && gs.getSession().isInteractive()) { + var qc = current.addQuery('u_hidden', '!=', 'true'); //cannot see hidden groups... + qc.addOrCondition('sys_id', 'javascript:getMyGroups()'); //...unless in the hidden group + gs.info('User has admin and groups admin roles'); + } else { + gs.info('User does not have both admin and groups admin roles'); + } +})(); +(function() { + if (current.operation() == 'insert') { + // If no due date was specified, calculate a default + if (current.due_date == '') { + if (current.urgency == '1') { + // Set due date to 4 hours ahead of current time + current.due_date = gs.hoursAgo(-4); + } + + if (current.urgency == '2') { + // Set due date to 2 days ahead of current time + current.due_date = gs.daysAgo(-2); + } + + if (current.urgency == '3') { + // Set due date to 7 days ahead of current time + current.due_date = gs.daysAgo(-7); + } + } + } +})(); +(function() { + gs.include('PrototypeServer'); +})(); +(function() { + gs.info('This is an info message'); + var myFirstName = 'Abel'; + var myLastName = 'Tuter'; + gs.info('This is an info message from {0}.{1}', myFirstName, myLastName); +})(); +(function() { + gs.debug('This is a log message'); + var myFirstName = 'Abel'; + var myLastName = 'Tuter'; + gs.debug('This is a log message from {0}.{1}', myFirstName, myLastName); + gs.info(gs.isDebugging()); +})(); +(function() { + if (!gs.hasRole('admin') && gs.getSession().isInteractive()) { + var qc1 = current.addQuery('u_group', ''); + var gra = new GlideRecord('sys_user_grmember'); + gra.addQuery('user', gs.getUserID()); + gra.query(); + while (gra.next()) { + qc1.addOrCondition('u_group', gra.group); + } + } +})(); +(function() { + gs.info(gs.isLoggedIn()); +})(); +(function() { + if (gs.isMobile()) gs.info('submitted from mobile UI'); + else gs.info('NOT submitted from mobile UI'); +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gs.nil(gr)); +})(); +(function() { + gs.setProperty('glide.foo', 'bar', 'foo'); + gs.info(gs.getProperty('glide.foo')); +})(); +(function() { + gs.setRedirect( + 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d41ce5bac611227a0167f4bf8109bf70&sysparm_user=' + + current.sys_id + + '&sysparm_email=' + + current.email + ); +})(); +(function() { + gs.info(gs.tableExists('incident')); +})(); +(function() { + gs.warn('This is a warning'); + var myFirstName = 'Abel'; + var myLastName = 'Tuter'; + gs.warn('This is a warning from {0}.{1}', myFirstName, myLastName); +})(); +(function() { + var xmlString = 'value'; + var jsonObject = gs.xmlToJSON(xmlString); + gs.info(jsonObject); +})(); diff --git a/types/servicenow-london/test/GlideTime.ts b/types/servicenow-london/test/GlideTime.ts new file mode 100644 index 0000000000..805e4da23a --- /dev/null +++ b/types/servicenow-london/test/GlideTime.ts @@ -0,0 +1,46 @@ +(function() { + var gt = new GlideTime(); + gs.info(gt.getDisplayValue()); +})(); +(function() { + var gt = new GlideTime(10000); + gs.info(gt.getDisplayValue()); +})(); +(function() { + var gt = new GlideTime(); + gt.setValue('12:00:00'); + gs.info(gt.getByFormat('HH:mm')); +})(); +(function() { + var gt = new GlideTime(); + gt.setDisplayValue('12:00:00'); // User Time Zone + gs.info(gt.getDisplayValue()); // User Time Zone +})(); +(function() { + var gt = new GlideTime(); + gt.setValue('01:00:00'); //Internal Time Zone , UTC + gs.info(gt.getDisplayValueInternal()); //User Time Zone +})(); +(function() { + var gt = new GlideTime(); + gs.info(gt.getValue()); // Internal Time Zone, UTC +})(); +(function() { + var gt = new GlideTime(); + gt.setDisplayValue('01:00:00'); // User Time Zone + gs.info(gt.getDisplayValueInternal()); // User Time Zone +})(); +(function() { + var gt = new GlideTime(); + gt.setValue('01:00:00'); //Internal Time Zone, UTC + gs.info('time is ' + gt.getByFormat('hh:mm:ss')); +})(); +(function() { + var gd1 = new GlideTime(); + gd1.setDisplayValue('09:00:00'); + var gd2 = new GlideTime(); + gd2.setDisplayValue('09:10:00'); + + var dur = GlideDate.subtract(gd1, gd2); //the difference between gdt1 and gdt2 + gs.info(dur.getDisplayValue()); +})(); diff --git a/types/servicenow-london/test/GlideUser.ts b/types/servicenow-london/test/GlideUser.ts new file mode 100644 index 0000000000..c554843db3 --- /dev/null +++ b/types/servicenow-london/test/GlideUser.ts @@ -0,0 +1,59 @@ +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getCompanyID()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getDisplayName()); +})(); +(function() { + var domain = new GlideRecord('domain'); + domain.get(gs.getUser().getDomainID()); + gs.info(domain.name); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getEmail()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getFirstName()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getID()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getLastName()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getName()); +})(); +(function() { + var currentUser = gs.getUser(); + currentUser.savePreference('myPref', 'red'); + gs.info(currentUser.getPreference('myPref')); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getRoles()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.getUserRoles()); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.hasRole('admin')); +})(); +(function() { + var currentUser = gs.getUser(); + gs.info(currentUser.isMemberOf('Capacity Mgmt')); +})(); +(function() { + var currentUser = gs.getUser(); + currentUser.savePreference('myPref', 'red'); + gs.info(currentUser.getPreference('myPref')); +})(); diff --git a/types/servicenow-london/test/RESTAPIRequest.ts b/types/servicenow-london/test/RESTAPIRequest.ts new file mode 100644 index 0000000000..14ec7ef8e3 --- /dev/null +++ b/types/servicenow-london/test/RESTAPIRequest.ts @@ -0,0 +1,22 @@ +function testRESTAPIRequest(request: sn_ws.RESTAPIRequest) { + var entry; + var id; + var requestBody = request.body; + var requestData = requestBody.data; + if (requestData instanceof Array) { + entry = requestData[0].name; + id = requestData[0].id; + } else { + entry = requestData.name; + id = requestData.id; + } + + var requestStream = requestBody.dataStream; + var requestString = requestBody.dataString; + requestBody.hasNext(); + requestBody.hasNext(); + var requestEntry = requestBody.nextEntry(); + + var name = requestEntry.name; + requestEntry = requestBody.nextEntry(); +} diff --git a/types/servicenow-london/test/RESTAPIRequestBody.ts b/types/servicenow-london/test/RESTAPIRequestBody.ts new file mode 100644 index 0000000000..6f4120d55f --- /dev/null +++ b/types/servicenow-london/test/RESTAPIRequestBody.ts @@ -0,0 +1,33 @@ +function testRESTAPIRequestBody(request: sn_ws.RESTAPIRequest) { + var requestBody = request.body; + // Returns instance of RESTAPIRequestBody + + var headers = request.headers; + var acceptHeader = headers.Accept; + var myCustomHeader = headers.myCustom; + var specialHeader = headers['special - header']; + var pathParams = request.pathParams; + var tableName = pathParams.tableName; + // "myApp_table" + + var id = pathParams.id; + // "1234" + + var queryParams = request.queryParams; + var isActiveQuery = queryParams.active; + // false + + var nameQueryVal = queryParams.name; + // "now" + + var query = request.queryString; + // "active=false&name=now" + + var query2 = request.uri; + // "api/now/table/myTable" + + var query3 = request.url; + // "https://instance.service-now.com/api/now/table/myTable?active=false&name=now" + + var acceptHeader = request.getHeader('accept'); +} diff --git a/types/servicenow-london/test/RESTAPIResponse.ts b/types/servicenow-london/test/RESTAPIResponse.ts new file mode 100644 index 0000000000..9938141393 --- /dev/null +++ b/types/servicenow-london/test/RESTAPIResponse.ts @@ -0,0 +1,28 @@ +function testRESTAPIResponse(response: sn_ws.RESTAPIResponse) { + response.setContentType('application/json'); + response.setStatus(200); + var writer = response.getStreamWriter(); + + var body: any = {}; + body.name = 'incident'; + body.number = '1234'; + body.caller = { id: 'user1' }; + response.setBody(body); + + var bodyArray = []; + body = {}; + body.name = 'incident'; + body.number = '1234'; + body.caller = { id: 'user1' }; + bodyArray.push(body); + response.setBody(bodyArray); + + response.setHeader('Location', ''); + + var headers: any = {}; + headers['X-Total-Count'] = 100; + headers.Location = 'https://instance.service-now.com/'; + response.setHeaders(headers); + + response.setStatus(200); +} diff --git a/types/servicenow-london/test/RESTAPIResponseStream.ts b/types/servicenow-london/test/RESTAPIResponseStream.ts new file mode 100644 index 0000000000..75f30d88d3 --- /dev/null +++ b/types/servicenow-london/test/RESTAPIResponseStream.ts @@ -0,0 +1,17 @@ +function testRESTAPIResponseStream(response: sn_ws.RESTAPIResponse, attachmentStream: any) { + response.setContentType('application/json'); + response.setStatus(200); + var writer = response.getStreamWriter(); + writer.writeStream(attachmentStream); + + response.setContentType('application/json'); + response.setStatus(200); + var writer = response.getStreamWriter(); + var body: any = { + name: 'user1', + id: 1234, + roles: [{ name: 'admin' }, { name: 'itil' }] + }; + writer.writeString("{'name':'user','id':'1234'}"); + writer.writeString(JSON.stringify(body)); +} diff --git a/types/servicenow-london/test/RESTMessageV2.ts b/types/servicenow-london/test/RESTMessageV2.ts new file mode 100644 index 0000000000..4368c70293 --- /dev/null +++ b/types/servicenow-london/test/RESTMessageV2.ts @@ -0,0 +1,106 @@ +(function() { + var sm = new sn_ws.RESTMessageV2('', 'get'); + var response = sm.execute(); + var response = sm.executeAsync(); + response.waitForResponse(60); + + var endpoint = sm.getEndpoint(); + var body = sm.getRequestBody(); + var header = sm.getRequestHeader('Accept'); + var headers = sm.getRequestHeaders(); + + sm.setBasicAuth('username', 'password'); + sm.setEccCorrelator('unique_identifier'); + sm.setEccParameter('source', 'http://very.long.endpoint.url'); + sm.setEndpoint('http://web.service.endpoint'); + sm.setHttpMethod('post'); + sm.setHttpTimeout(6000); + sm.setLogLevel('all'); + sm.setMIDServer('mid_server_name'); + sm.setMutualAuth('mutual_auth_profile_name'); + sm.setQueryParameter('sysparm_query', 'active=true^ORDERBYnumber^ORDERBYDESCcategory'); + sm.setRequestHeader('Accept', 'Application/json'); + sm.setStringParameter('s', 'NOW'); + sm.setStringParameterNoEscape('s', 'NOW'); + + var body = ''; + sm.setRequestBody(body); +})(); +(function sampleRESTMessageV2() { + try { + var request = new sn_ws.RESTMessageV2(); + request.setHttpMethod('get'); + + var attachment_sys_id = '', + tablename = 'incident', + recordSysId = '', + response, + httpResponseStatus, + filename = ''; + + //endpoint - ServiceNow REST Attachment API + request.setEndpoint( + 'https://.service-now.com/api/now/attachment/' + + attachment_sys_id + + '/file' + ); + request.setBasicAuth('', ''); + + //RESTMessageV2 - saveResponseBodyAsAttachment(String tableName, String recordSysId, String fileName) + request.saveResponseBodyAsAttachment(tablename, recordSysId, filename); + + response = request.execute(); + httpResponseStatus = response.getStatusCode(); + + gs.info(' http response status_code: ' + httpResponseStatus); + } catch (ex) { + var message = ex.getMessage(); + gs.info(message); + } +})(); +(function() { + var requestBody; + var response; + var responseBody; + var status; + var sm; + try { + // Might throw exception if message doesn't exist or not visible due to scope. + sm = new sn_ws.RESTMessageV2('', 'get'); + + //set auth profile to an OAuth 2.0 profile record. + sm.setAuthenticationProfile('oauth2', '1234adsf123212131123qasdsf'); + + sm.setStringParameter('symbol', 'NOW'); + sm.setStringParameterNoEscape('xml_data', 'test'); + + //In milliseconds. Wait at most 10 seconds for response from http request. + sm.setHttpTimeout(10000); + //Might throw exception if http connection timed out or some issue + //with sending request itself because of encryption/decryption of password. + response = sm.execute(); + responseBody = response.haveError() ? response.getErrorMessage() : response.getBody(); + status = response.getStatusCode(); + } catch (ex) { + responseBody = ex.getMessage(); + status = '500'; + } finally { + requestBody = sm ? sm.getRequestBody() : null; + } +})(); +(function sampleRESTMessageV2() { + try { + var request = new sn_ws.RESTMessageV2(); + request.setHttpMethod('post'); + request.setEndpoint(''); + request.setRequestBodyFromAttachment(''); + + var response = request.execute(); + var httpResponseStatus = response.getStatusCode(); + + gs.info('http response status_code: ' + httpResponseStatus); + } catch (ex) { + var message = ex.getMessage(); + gs.info(message); + } +})(); diff --git a/types/servicenow-london/test/RESTResponseV2.ts b/types/servicenow-london/test/RESTResponseV2.ts new file mode 100644 index 0000000000..79ede22cc4 --- /dev/null +++ b/types/servicenow-london/test/RESTResponseV2.ts @@ -0,0 +1,22 @@ +(function() { + var sm = new sn_ws.RESTMessageV2('
', 'get'); + var response = sm.execute(); + var allHeaders = response.getAllHeaders(); + for (var header in allHeaders) { + gs.info(allHeaders[header].name + ': ' + allHeaders[header].value); + } + var cookies = response.getCookies(); + for (var i = 0; i < cookies.size(); i++) { + gs.info('cookie: ' + cookies.get(i)); + } + var responseBody = response.getBody(); + var errorCode = response.getErrorCode(); + var errorMsg = response.getErrorMessage(); + var headerVal = response.getHeader('Content-Type'); + var headers = response.getHeaders(); + var queryString = response.getQueryString(); + var statusCode = response.getStatusCode(); + var error = response.haveError(); + var response = sm.executeAsync(); + response.waitForResponse(60); +})(); diff --git a/types/servicenow-london/test/SOAPMessageV2.ts b/types/servicenow-london/test/SOAPMessageV2.ts new file mode 100644 index 0000000000..5181a9be3b --- /dev/null +++ b/types/servicenow-london/test/SOAPMessageV2.ts @@ -0,0 +1,28 @@ +(function() { + var sm = new sn_ws.SOAPMessageV2(); + sm = new sn_ws.SOAPMessageV2('StockQuote', 'GetQuote'); + var response = sm.execute(); + response = sm.executeAsync(); + var endpoint = sm.getEndpoint(); + var requestBody = sm.getRequestBody(); + var header = sm.getRequestHeader('Accept'); + var requestHeaders = sm.getRequestHeaders(); + sm.setBasicAuth('username', 'password'); + sm.setEccCorrelator('unique_id'); + sm.setEccParameter('source', 'http://very.long.endpoint'); + sm.setEndpoint('http://web.service.endpoint'); + sm.setHttpTimeout(6000); + sm.setMutualAuth('auth_profile_name'); + var body = ''; + sm.setRequestBody(body); + sm.setRequestHeader('Accept', 'Application/json'); + sm.setSOAPAction('GetQuote'); + sm.setStringParameter('symbol', 'NOW'); + sm.setStringParameterNoEscape('symbol', 'NOW'); + sm.setWSSecurity( + '70d65e074f3812001f6eac118110c71a', + 'Quote keys', + 'UXr82cqX75Z7MaSa+EyjGA==', + 'ba969a074f3812001f6eac118110c76d' + ); +})(); diff --git a/types/servicenow-london/test/SOAPResponseV2.ts b/types/servicenow-london/test/SOAPResponseV2.ts new file mode 100644 index 0000000000..c7a4c181a3 --- /dev/null +++ b/types/servicenow-london/test/SOAPResponseV2.ts @@ -0,0 +1,20 @@ +(function() { + var r = new sn_ws.SOAPMessageV2('', 'get'); + var response = r.execute(); + var allHeaders = response.getAllHeaders(); + for (var h in allHeaders) { + gs.info(allHeaders[h].name + ': ' + allHeaders[h].value); + } + var body = response.getBody(); + var cookies = response.getCookies(); + for (var i = 0; i < cookies.size(); i++) { + gs.info('cookie: ' + cookies.get(i)); + } + var errorCode = response.getErrorCode(); + var errorMsg = response.getErrorMessage(); + var headerVal = response.getHeader("Accept"); + var headers = response.getHeaders(); + var statusCode = response.getStatusCode(); + var error = response.haveError(); + response.waitForResponse(60); +})(); diff --git a/types/servicenow-london/test/ScopedElementDescriptor.ts b/types/servicenow-london/test/ScopedElementDescriptor.ts new file mode 100644 index 0000000000..a0da98ba85 --- /dev/null +++ b/types/servicenow-london/test/ScopedElementDescriptor.ts @@ -0,0 +1,19 @@ +(function() { + var gr = new GlideRecord('incident'); + gr.query('priority', '1'); + var field = gr.getElement('priority'); + var ed = field.getED(); + + var s = ed.getAttachmentEncryptionType(); + s = ed.getEncryptionType(); + s = ed.getInternalType(); + s = ed.getLabel(); + var n = ed.getLength(); + s = ed.getName(); + s = ed.getPlural(); + var b = ed.hasAttachmentsEncrypted(); + b = ed.isAutoOrSysID(); + b = ed.isChoiceTable(); + b = ed.isEdgeEncrypted(); + b = ed.isVirtual(); +})(); diff --git a/types/servicenow-london/test/ScopedGlideElement.ts b/types/servicenow-london/test/ScopedGlideElement.ts new file mode 100644 index 0000000000..8d749d848e --- /dev/null +++ b/types/servicenow-london/test/ScopedGlideElement.ts @@ -0,0 +1,13 @@ +(function() { + var gr = new GlideRecord('incident'); + var el = gr.getElement('active'); + var b = el.changes(); + b = el.changesFrom(true); + b = el.changesTo(false); + var s = el.getAttribute('tree_picker'); + var sa = el.getChoices(); + s = el.getChoiceValue(); + s = el.getDecryptedValue(); + s = el.getDisplayValue(); + var ed = el.getED(); +})(); diff --git a/types/servicenow-london/test/ScopedGlideRecord.ts b/types/servicenow-london/test/ScopedGlideRecord.ts new file mode 100644 index 0000000000..d2a2ed715a --- /dev/null +++ b/types/servicenow-london/test/ScopedGlideRecord.ts @@ -0,0 +1,400 @@ +interface ScopedGlideRecord { + new (tableName: 'othertype'): OtherType; +} +interface OtherType extends ScopedGlideRecord { + someproperty: string; +} +(function testMerging() { + var gr = new GlideRecord('othertype'); + gr.someproperty = 'foo'; +})(); +(function() { + var inc = new GlideRecord('incident'); + inc.addActiveQuery(); + inc.query(); +})(); +(function() { + var queryString = 'priority=1^ORpriority=2'; + var gr = new GlideRecord('incident'); + gr.addEncodedQuery(queryString); + gr.query(); + while (gr.next()) { + gs.addInfoMessage(gr.number); + } +})(); +(function() { + var functionBuilder = new GlideDBFunctionBuilder(); + var myAddingFunction = functionBuilder.add(); + myAddingFunction = functionBuilder.field('order'); + myAddingFunction = functionBuilder.field('priority'); + var func = functionBuilder.build(); + + var gr = new GlideRecord('incident'); + gr.addFunction(func); + gr.addQuery(func, '<', 5); + gr.query(); + while (gr.next()) gs.info(gr.getValue(func)); +})(); +(function() { + var prob = new GlideRecord('problem'); + prob.addJoinQuery('incident'); + prob.query(); +})(); +(function() { + // Look for Problem records that have associated Incident records + var gr = new GlideRecord('problem'); + var grSQ = gr.addJoinQuery('incident'); + + // Where the Problem records are "active=false" + gr.addQuery('active', 'false'); + + // And the Incident records are "active=true" + grSQ.addCondition('active', 'true'); + + // Query + gr.query(); + + // Iterate and output results + while (gr.next()) { + gs.info(gr.getValue('number')); + } +})(); +(function() { + var gr = new GlideRecord('problem'); + gr.addJoinQuery('incident', 'opened_by', 'caller_id'); + gr.query(); +})(); +(function() { + var target = new GlideRecord('incident'); + target.addNotNullQuery('short_description'); + target.query(); // Issue the query to the database to get all records where short_description is not null + while (target.next()) { + // add code here to process the incident record + } +})(); +(function() { + var target = new GlideRecord('incident'); + target.addNullQuery('short_description'); + target.query(); // Issue the query to the database to get all records where short_description is null + while (target.next()) { + // add code here to process the incident record + } +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.addQuery('active', true); + rec.query(); + while (rec.next()) { + rec.active = false; + gs.info('Active incident ' + rec.number + ' closed'); + rec.update(); + } +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.addQuery('active', true); + rec.addQuery('sys_created_on', '>', '2010-01-19 04:05:00'); + rec.query(); + while (rec.next()) { + rec.active = false; + gs.info('Active incident ' + rec.number + ' closed'); + rec.update(); + } +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.addQuery('number', 'IN', 'INC00001,INC00002'); + gr.query(); + while (gr.next()) { + //do something.... + } +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.addQuery('active=true'); + rec.query(); + while (rec.next()) { + rec.active = false; + gs.info('Active incident ' + rec.number + ' closed'); + rec.update(); + } +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gr.canCreate()); + gs.info(gr.canDelete()); + gs.info(gr.canRead()); + gs.info(gr.canWrite()); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.orderBy('number'); + gr.chooseWindow(2, 4); + gr.query(); + if (gr.next()) { + gs.info(gr.number + ' is within window'); + } +})(); +(function() { + var inc = new GlideRecord('incident'); + inc.get('17c90efb13418700cc36b1422244b05d'); + gs.info(inc.calendar_duration.dateNumericValue()); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.addQuery('active', 'false'); //to delete all inactive incidents + gr.deleteMultiple(); +})(); +(function() { + var gr = new GlideRecord('incident'); + //to delete one record + if (gr.get('99ebb4156fa831005be8883e6b3ee4b9')) { + gr.deleteRecord(); + } +})(); +(function() { + var grIncident = new GlideRecord('incident'); + var returnValue = grIncident.get('99ebb4156fa831005be8883e6b3ee4b9'); + gs.info(returnValue); // logs true or false + gs.info(grIncident.number); // logs Incident Number +})(); +(function() { + var grIncident = new GlideRecord('incident'); + var returnValue = grIncident.get('caller_id.name', 'Sylivia Wayland'); + gs.info(returnValue); // logs true or false + gs.info(grIncident.number); // logs Incident Number +})(); +doit(); +function doit() { + var gr = new GlideRecord('sys_user'); + gr.query('user_name', 'admin'); + if (gr.next()) { + gs.info('we got one'); + gs.info(gr.location.getAttribute('tree_picker')); + } +} +(function() { + var gr = new GlideRecord('incident'); + gr.get('sys_id', 'ef43c6d40a0a0b5700c77f9bf387afe3'); + gs.info(gr.getDisplayValue()); +})(); +(function() { + var gr = new GlideRecord('incident'); + var ed = gr.getED(); + gs.info(ed.getLabel()); +})(); +(function() { + var elementName = 'short_description'; + var gr = new GlideRecord('incident'); + gr.initialize(); + gr.setValue(elementName, 'My DB is not working'); + gr.insert(); + gs.info(gr.getElement('short_description')); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.addQuery('active', true); + gr.addQuery('priority', 1); + gr.query(); + var encodedQuery = gr.getEncodedQuery(); + gs.info(encodedQuery); +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gr.getLabel()); +})(); +(function() { + // Setup a data policy where short_description field in incident is mandatory + var gr = new GlideRecord('incident'); + gr.insert(); // insert without data in mandatory field + var errormessage = gr.getLastErrorMessage(); + gs.info(errormessage); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.addActiveQuery(); + gr.addQuery('priority', 1); + gr.query(); + gr.next(); + gs.info(gs.getProperty('glide.servlet.uri') + gr.getLink(false)); +})(); +(function() { + var gr = new GlideRecord('incident'); + var recordClassName = gr.getRecordClassName(); + gs.info(recordClassName); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.query(); + gs.info('Records in incident table: ' + gr.getRowCount()); +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gr.getTableName()); +})(); +(function() { + var gr = new GlideRecord('kb_knowledge'); + gr.query(); + gr.next(); + var uniqueid = gr.getUniqueValue(); + gs.info(uniqueid); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.orderBy('number'); + gr.query('active', 'true'); + gr.next(); + gs.info(gr.getValue('number')); +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.query(); + if (rec.hasNext()) { + gs.info('Table is not empty'); + } +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.initialize(); + gr.name = 'New Incident'; + gr.description = 'Incident description'; + gr.insert(); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.initialize(); + gr.name = 'New Incident'; + gr.description = 'Incident description'; + gr.insert(); +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gr.isActionAborted()); +})(); +(function() { + var gr = new GlideRecord('x_app_table'); + gr.newRecord(); // create a new record and populate it with default values + gs.info(gr.isNewRecord()); +})(); +(function() { + var gr = new GlideRecord('incident'); + gs.info(gr.isValid()); + var anotherGr = new GlideRecord('wrong_table_name'); + gs.info(anotherGr.isValid()); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.initialize(); + gs.info(gr.isValidField('short_description')); +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.query(); + while (rec.next()) { + gs.info(rec.number + ' exists'); + } + gs.info(rec.isValidRecord()); +})(); +(function() { + var gr = new GlideRecord('x_app_table'); + gr.newRecord(); + gs.info(gr.isNewRecord()); +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.query(); + while (rec.next()) { + gs.info(rec.number + ' exists'); + } +})(); +(function() { + //Commonly used in a business rule, returns insert if the current operation is insert + gs.info('current operation ' + current.operation()); +})(); +(function() { + var queryString = 'priority=2'; + var gr = new GlideRecord('incident'); + gr.orderBy('short_description'); // Ascending Order + gr.addEncodedQuery(queryString); + gr.query(); + while (gr.next()) { + gs.info(gr.short_description); + } +})(); +(function() { + var queryString = 'priority=2'; + var gr = new GlideRecord('incident'); + gr.orderByDesc('short_description'); //Descending Order + gr.addEncodedQuery(queryString); + gr.query(); + while (gr.next()) { + gs.info(gr.short_description); + } +})(); +(function() { + var rec = new GlideRecord('incident'); + rec.query(); + while (rec.next()) { + gs.info(rec.number + ' exists'); + } +})(); +(function() { + // Often used in business rule to check whether the current operation should be aborted. + if (current.size > 16) { + current.setAbortAction(true); + } +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.orderByDesc('sys_created_on'); + gr.setLimit(10); + gr.query(); // this retrieves latest 10 incident records created +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.short_description = 'The third floor printer is broken'; + gr.setNewGuidValue('eb4636ca6f6d31005be8883e6b3ee333'); + gr.insert(); + gs.info(gr.sys_id); +})(); +(function() { + var elementName = 'short_description'; + var gr = new GlideRecord('incident'); + gr.initialize(); + gr.setValue(elementName, 'My DB is not working'); + gr.insert(); +})(); +(function() { + //Enable business rules, scripts engines for x_app_table + var gr = new GlideRecord('x_app_table'); + gr.setWorkflow(true); +})(); +(function() { + var gr = new GlideRecord('incident'); + gr.get('99ebb4156fa831005be8883e6b3ee4b9'); + gr.short_description = 'Update the short description'; + gr.update(); + gs.info(gr.getElement('short_description')); +})(); +(function() { + // update the state of all active incidents to 4 - "Awaiting User Info" + var gr = new GlideRecord('incident'); + gr.addQuery('active', true); + gr.query(); + gr.setValue('state', 4); + gr.updateMultiple(); +})(); +(function() { + var rec = new GlideRecord('sys_template'); + rec.query(); + while (rec._next()) { + gs.info(rec.number + ' exists'); + } +})(); +(function() { + var rec = new GlideRecord('sys_app_module'); + rec._query(); + while (rec.next()) { + gs.info(rec.number + ' exists'); + } +})(); diff --git a/types/servicenow-london/test/ScopedQueryCondition.ts b/types/servicenow-london/test/ScopedQueryCondition.ts new file mode 100644 index 0000000000..3a818b966a --- /dev/null +++ b/types/servicenow-london/test/ScopedQueryCondition.ts @@ -0,0 +1,26 @@ +(function() { + var gr = new GlideRecord('incident'); + var qc = gr.addQuery('category', 'Hardware'); + qc.addCondition('category', 'Network'); + gr.addQuery('number', 'INC0000003'); + gr.next(); + gr.number; + gs.info(gr.getEncodedQuery()); +})(); +(function() { + var gr = new GlideRecord('incident'); + var qc = gr.addQuery('category', 'Hardware'); + qc.addOrCondition('category', 'Network'); + gr.addQuery('number', 'INC0000003'); + gr.next(); + gr.number; + gs.info(gr.getEncodedQuery()); +})(); +(function() { + var myObj = new GlideRecord('incident'); + var q1 = myObj.addQuery('state', '<', 3); + q1.addOrCondition('state', '>', 5); + var q2 = myObj.addQuery('priority', 1); + q2.addOrCondition('priority', 5); + myObj.query(); +})(); diff --git a/types/servicenow-london/test/Workflow.ts b/types/servicenow-london/test/Workflow.ts new file mode 100644 index 0000000000..bbe5710899 --- /dev/null +++ b/types/servicenow-london/test/Workflow.ts @@ -0,0 +1,134 @@ +(function() { + var gr = new GlideRecord('change_request'); + gr.get('8ecd7552db252200a6a2b31be0b8f581'); + + var wf = new global.Workflow(); + var grFlows = wf.getRunningFlows(gr); + while (grFlows.next()) { + wf.broadcastEvent(grFlows.sys_id, 'resume'); + } +})(); +(function() { + var gr = new GlideRecord('change_request'); + gr.get('8ecd7552db252200a6a2b31be0b8f581'); + + var wf = new global.Workflow(); + wf.cancel(gr); +})(); +(function() { + // If a workflow has started for this item, cancel it, where current is a task record with a workflow context + if (current.stage == 'Request Cancelled' && current.context && !current.context.nil()) { + var w = new global.Workflow(); + var gr = new GlideRecord('wf_context'); + + if (gr.get(current.context)) w.cancelContext(gr); + } +})(); +(function() { + var wkfw = new global.Workflow(); + wkfw.deleteWorkflow(current); +})(); +(function() { + // where current is a task record with a workflow context + var w = new global.Workflow(); + w.fireEvent(current, 'execute'); +})(); +(function() { + var wkfw = new global.Workflow(); + wkfw.fireEventById('f2400ec10b0a3c1c00ca5bb5c6fae427', 'Timer'); +})(); +(function() { + //where current is a task record with a workflow context + var wkfw = new global.Workflow(); + gs.info(wkfw.getContexts(current).started); +})(); +(function() { + var wkfw = new global.Workflow(); + gs.info(wkfw.getEstimatedDeliveryTime('b99a866a4a3623120074c033e005418f')); +})(); +(function() { + //where current is a task record with a workflow context + var wkfw = new global.Workflow(); + var context = wkfw.getContexts(current); + gs.info(wkfw.getEstimatedDeliveryTimeFromWFVersion(context.wf_version)); +})(); +(function() { + var gr = new GlideRecord('wf_context'); + gr.get('08a90c3adba52200a6a2b31be0b8f565'); + var wkfw = new global.Workflow(); + wkfw.getReturnValue(gr); +})(); +(function() { + //where current is a task record with a workflow context + var wf = new global.Workflow().getRunningFlows(current); + while (wf.next()) { + new global.Workflow().broadcastEvent(wf.sys_id, 'pause'); + } +})(); +(function() { + var wkfw = new global.Workflow(); + var gr = wkfw.getVersion('b99a866a4a3623120074c033e005418f'); +})(); +(function() { + var wkfw = new global.Workflow(); + var ge = wkfw.getVersionFromName('Emergency Change'); +})(); +(function() { + var wkfw = new global.Workflow(); + var s = wkfw.getWorkflowFromName('Emergency Change'); +})(); +(function() { + var gr = new GlideRecord('change_request'); + gr.get('cecdb552db252200a6a2b31be0b8f50b'); + var wkfw = new global.Workflow(); + gs.info(wkfw.hasWorkflow(gr)); +})(); +(function() { + var gr = new GlideRecord('change_request'); + gr.get('cecdb552db252200a6a2b31be0b8f50b'); + new global.Workflow().restartWorkflow(gr); +})(); +(function() { + var gr = new GlideRecord('change_request'); + gr.get('cecdb552db252200a6a2b31be0b8f50b'); + var wkfw = new global.Workflow(); + wkfw.runFlows(gr, 'update'); +})(); +(function() { + ////where current is a task record with a workflow context + var w = new global.Workflow(); + var context = w.startFlow('sys_id', current, current.operation(), {}); +})(); +(function() { + //where current is a task record with a workflow context + current.name = current.workflow_version.name; + current.started_by.setValue(gs.getUserID()); + + if (gs.nil(current.id)) { + var gr = new GlideRecord('wf_workflow_execution'); + gr.name = current.name; + gr.insert(); + + current.table = 'wf_workflow_execution'; + current.id = gr.sys_id; + } + + var wf = new global.Workflow(); + wf.startFlowFromContextInsert(current, current.operation()); +})(); +(function() { + var id = 'sys_id'; + // is this a retroactive start? + ////where current is a task record with a workflow context + var msecs = + new GlideDateTime().getNumericValue() - + current.start_time.getGlideObject().getNumericValue(); + + // treat this as a retroactive workflow start if the SLA started more than 5 seconds ago + var w = new global.Workflow(); + if (msecs <= 5000) w.startFlow(id, current, current.operation()); + else w.startFlowRetroactive(id, msecs, current, current.operation()); + + // update the record in case the workflow changed some values + current.update(); +})(); diff --git a/types/servicenow-london/test/XMLDocument2.ts b/types/servicenow-london/test/XMLDocument2.ts new file mode 100644 index 0000000000..5ef77cc906 --- /dev/null +++ b/types/servicenow-london/test/XMLDocument2.ts @@ -0,0 +1,153 @@ +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + xmlDoc.createElement('new2'); + + gs.info(xmlDoc); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + xmlDoc.createElementWithTextValue('new', 'test'); + gs.info(xmlDoc); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + //returns the root node of the document tree. + var rootNode = xmlDoc.getDocumentElement(); + gs.info(rootNode.getTextContent()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var foo = xmlDoc.getFirstNode('/test/one/two'); + gs.info(foo.getTextContent()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var foo = xmlDoc.getFirstNode('/test/one/two'); + var foo2 = xmlDoc.getNextNode(foo); + gs.info(foo.getTextContent()); + gs.info(foo2.getTextContent()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('/test/one/two'); + gs.info(node); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + gs.info(xmlDoc.getNodeText('//two')); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var rootNode = xmlDoc.getDocumentElement(); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + //returns the root node of the document tree. + var rootNode = xmlDoc.getDocumentElement(); //returns org.w3c.dom.Element + // sets the root node as the current element + xmlDoc.setCurrentElement(rootNode); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + gs.info(xmlDoc.toString()); +})(); diff --git a/types/servicenow-london/test/XMLNode.ts b/types/servicenow-london/test/XMLNode.ts new file mode 100644 index 0000000000..a5db5cd6ed --- /dev/null +++ b/types/servicenow-london/test/XMLNode.ts @@ -0,0 +1,137 @@ +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//two'); + gs.info(node.getAttribute('att')); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + var iter = node.getChildNodeIterator(); + gs.info(iter.hasNext()); +})(); +(function() { + var xmlString = + '' + + '' + + 'abcd1234' + + '1234abcd' + + 'another' + + '' + + '1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + gs.info(node.getFirstChild()); +})(); +(function() { + var xmlString = + '' + + '' + + 'abcd1234' + + '1234abcd' + + 'another' + + '' + + '1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + + gs.info(node.getLastChild()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//two'); + gs.info(node.getNodeName()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//two'); + gs.info(node.getNodeValue()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmldoc = new XMLDocument2(); + xmldoc.parseXML(xmlString); + var node = xmldoc.getNode('//one/two'); + gs.info(node.getTextContent()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//two'); + gs.info(node.hasAttribute('att')); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + gs.info(node.toString()); +})(); diff --git a/types/servicenow-london/test/XMLNodeIterator.ts b/types/servicenow-london/test/XMLNodeIterator.ts new file mode 100644 index 0000000000..50e58e8f83 --- /dev/null +++ b/types/servicenow-london/test/XMLNodeIterator.ts @@ -0,0 +1,36 @@ +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + var iter = node.getChildNodeIterator(); + gs.info(iter.hasNext()); +})(); +(function() { + var xmlString = + '' + + ' ' + + ' abcd1234' + + ' 1234abcd' + + ' another' + + ' ' + + ' 1234' + + ''; + var xmlDoc = new XMLDocument2(); + xmlDoc.parseXML(xmlString); + var node = xmlDoc.getNode('//one'); + var iter = node.getChildNodeIterator(); + while (iter.hasNext()) { + var n = iter.next(); + gs.info('Node name: ' + n.getNodeName()); + gs.info('Node value: ' + n.getNodeValue()); + } +})(); diff --git a/types/servicenow-london/tsconfig.json b/types/servicenow-london/tsconfig.json new file mode 100644 index 0000000000..53dd1d713d --- /dev/null +++ b/types/servicenow-london/tsconfig.json @@ -0,0 +1,97 @@ +{ + "compilerOptions": { + "lib": ["es5"], + "module": "commonjs", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + + "Class.d.ts", + "GlideDate.d.ts", + "GlideDateTime.d.ts", + "GlideDBFunctionBuilder.d.ts", + "GlideDuration.d.ts", + "GlideEmailOutbound.d.ts", + "GlideFilter.d.ts", + "GlideLocale.d.ts", + "GlidePluginManager.d.ts", + "GlideRecordOperation.d.ts", + "GlideSchedule.d.ts", + "GlideScopedEvaluator.d.ts", + "GlideScriptedProcessor.d.ts", + "GlideSecureRandomUtil.d.ts", + "GlideServletRequest.d.ts", + "GlideServletResponse.d.ts", + "GlideSession.d.ts", + "GlideStringUtil.d.ts", + "GlideSysAttachment.d.ts", + "GlideSystem.d.ts", + "GlideTime.d.ts", + "GlideUser.d.ts", + "QueryOperator.d.ts", + "RenderProperties.d.ts", + "RESTAPIRequest.d.ts", + "RESTAPIRequestBody.d.ts", + "RESTAPIResponse.d.ts", + "RESTAPIResponseStream.d.ts", + "RESTMessageV2.d.ts", + "RESTResponseV2.d.ts", + "ScopedElementDescriptor.d.ts", + "ScopedGlideElement.d.ts", + "ScopedGlideRecord.d.ts", + "ScopedQueryCondition.d.ts", + "SOAPMessageV2.d.ts", + "SOAPResponseV2.d.ts", + "Workflow.d.ts", + "XMLDocument2.d.ts", + "XMLNode.d.ts", + "XMLNodeIterator.d.ts", + + "test/Class.ts", + "test/GlideDate.ts", + "test/GlideDateTime.ts", + "test/GlideDBFunctionBuilder.ts", + "test/GlideDuration.ts", + "test/GlideEmailOutbound.ts", + "test/GlideFilter.ts", + "test/GlideLocale.ts", + "test/GlidePluginManager.ts", + "test/GlideSchedule.ts", + "test/GlideScopedEvaluator.ts", + "test/GlideScriptedProcessor.ts", + "test/GlideSecureRandomUtil.ts", + "test/GlideServletRequest.ts", + "test/GlideServletResponse.ts", + "test/GlideSession.ts", + "test/GlideStringUtil.ts", + "test/GlideSysAttachment.ts", + "test/GlideSystem.ts", + "test/GlideTime.ts", + "test/GlideUser.ts", + "test/RESTAPIRequest.ts", + "test/RESTAPIRequestBody.ts", + "test/RESTAPIResponse.ts", + "test/RESTAPIResponseStream.ts", + "test/RESTMessageV2.ts", + "test/RESTResponseV2.ts", + "test/ScopedElementDescriptor.ts", + "test/ScopedGlideElement.ts", + "test/ScopedGlideRecord.ts", + "test/ScopedQueryCondition.ts", + "test/SOAPMessageV2.ts", + "test/SOAPResponseV2.ts", + "test/Workflow.ts", + "test/XMLDocument2.ts", + "test/XMLNode.ts", + "test/XMLNodeIterator.ts" + ] +} diff --git a/types/servicenow-london/tslint.json b/types/servicenow-london/tslint.json new file mode 100644 index 0000000000..1e1f71979b --- /dev/null +++ b/types/servicenow-london/tslint.json @@ -0,0 +1,12 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // Interface is needed for merging GlideRecord types + "no-misused-new": false, + // Disabling to all separate JSDoc per signature to correspond with ServiceNow API docs + "unified-signatures": false + }, + "linterOptions": { + "exclude": ["test/*.ts"] + } +} From e594fe950d17e9e08619c35b46b8414df0333bc3 Mon Sep 17 00:00:00 2001 From: John Caruso Date: Mon, 25 Mar 2019 17:20:58 -0500 Subject: [PATCH 2/6] Remove non-lintable tests --- .../servicenow-london-tests.ts | 24 ++ types/servicenow-london/test/Class.ts | 11 - .../test/GlideDBFunctionBuilder.ts | 75 ---- types/servicenow-london/test/GlideDate.ts | 18 - types/servicenow-london/test/GlideDateTime.ts | 100 ----- types/servicenow-london/test/GlideDuration.ts | 46 -- .../test/GlideEmailOutbound.ts | 21 - types/servicenow-london/test/GlideFilter.ts | 10 - types/servicenow-london/test/GlideLocale.ts | 15 - .../test/GlidePluginManager.ts | 18 - types/servicenow-london/test/GlideSchedule.ts | 62 --- .../test/GlideScopedEvaluator.ts | 34 -- .../test/GlideScriptedProcessor.ts | 16 - .../test/GlideSecureRandomUtil.ts | 12 - .../test/GlideServletRequest.ts | 26 -- .../test/GlideServletResponse.ts | 10 - types/servicenow-london/test/GlideSession.ts | 64 --- .../servicenow-london/test/GlideStringUtil.ts | 85 ---- .../test/GlideSysAttachment.ts | 1 - types/servicenow-london/test/GlideSystem.ts | 211 --------- types/servicenow-london/test/GlideTime.ts | 46 -- types/servicenow-london/test/GlideUser.ts | 59 --- .../servicenow-london/test/RESTAPIRequest.ts | 22 - .../test/RESTAPIRequestBody.ts | 33 -- .../servicenow-london/test/RESTAPIResponse.ts | 28 -- .../test/RESTAPIResponseStream.ts | 17 - types/servicenow-london/test/RESTMessageV2.ts | 106 ----- .../servicenow-london/test/RESTResponseV2.ts | 22 - types/servicenow-london/test/SOAPMessageV2.ts | 28 -- .../servicenow-london/test/SOAPResponseV2.ts | 20 - .../test/ScopedElementDescriptor.ts | 19 - .../test/ScopedGlideElement.ts | 13 - .../test/ScopedGlideRecord.ts | 400 ------------------ .../test/ScopedQueryCondition.ts | 26 -- types/servicenow-london/test/Workflow.ts | 134 ------ types/servicenow-london/test/XMLDocument2.ts | 153 ------- types/servicenow-london/test/XMLNode.ts | 137 ------ .../servicenow-london/test/XMLNodeIterator.ts | 36 -- types/servicenow-london/tsconfig.json | 38 +- types/servicenow-london/tslint.json | 9 - 40 files changed, 25 insertions(+), 2180 deletions(-) create mode 100644 types/servicenow-london/servicenow-london-tests.ts delete mode 100644 types/servicenow-london/test/Class.ts delete mode 100644 types/servicenow-london/test/GlideDBFunctionBuilder.ts delete mode 100644 types/servicenow-london/test/GlideDate.ts delete mode 100644 types/servicenow-london/test/GlideDateTime.ts delete mode 100644 types/servicenow-london/test/GlideDuration.ts delete mode 100644 types/servicenow-london/test/GlideEmailOutbound.ts delete mode 100644 types/servicenow-london/test/GlideFilter.ts delete mode 100644 types/servicenow-london/test/GlideLocale.ts delete mode 100644 types/servicenow-london/test/GlidePluginManager.ts delete mode 100644 types/servicenow-london/test/GlideSchedule.ts delete mode 100644 types/servicenow-london/test/GlideScopedEvaluator.ts delete mode 100644 types/servicenow-london/test/GlideScriptedProcessor.ts delete mode 100644 types/servicenow-london/test/GlideSecureRandomUtil.ts delete mode 100644 types/servicenow-london/test/GlideServletRequest.ts delete mode 100644 types/servicenow-london/test/GlideServletResponse.ts delete mode 100644 types/servicenow-london/test/GlideSession.ts delete mode 100644 types/servicenow-london/test/GlideStringUtil.ts delete mode 100644 types/servicenow-london/test/GlideSysAttachment.ts delete mode 100644 types/servicenow-london/test/GlideSystem.ts delete mode 100644 types/servicenow-london/test/GlideTime.ts delete mode 100644 types/servicenow-london/test/GlideUser.ts delete mode 100644 types/servicenow-london/test/RESTAPIRequest.ts delete mode 100644 types/servicenow-london/test/RESTAPIRequestBody.ts delete mode 100644 types/servicenow-london/test/RESTAPIResponse.ts delete mode 100644 types/servicenow-london/test/RESTAPIResponseStream.ts delete mode 100644 types/servicenow-london/test/RESTMessageV2.ts delete mode 100644 types/servicenow-london/test/RESTResponseV2.ts delete mode 100644 types/servicenow-london/test/SOAPMessageV2.ts delete mode 100644 types/servicenow-london/test/SOAPResponseV2.ts delete mode 100644 types/servicenow-london/test/ScopedElementDescriptor.ts delete mode 100644 types/servicenow-london/test/ScopedGlideElement.ts delete mode 100644 types/servicenow-london/test/ScopedGlideRecord.ts delete mode 100644 types/servicenow-london/test/ScopedQueryCondition.ts delete mode 100644 types/servicenow-london/test/Workflow.ts delete mode 100644 types/servicenow-london/test/XMLDocument2.ts delete mode 100644 types/servicenow-london/test/XMLNode.ts delete mode 100644 types/servicenow-london/test/XMLNodeIterator.ts diff --git a/types/servicenow-london/servicenow-london-tests.ts b/types/servicenow-london/servicenow-london-tests.ts new file mode 100644 index 0000000000..a976b80bf0 --- /dev/null +++ b/types/servicenow-london/servicenow-london-tests.ts @@ -0,0 +1,24 @@ +const NewInclude = Class.create(); + +const grFirst = new GlideRecord('core_company'); + +const grSecond = new GlideRecord('core_company'); +grSecond.addQuery('property', '=', grFirst.sys_id); +grSecond.addQuery('property2', '!=', 'somevalue'); +if (grSecond.get('somesysid')) { + gs.info('got it'); +} + +const wf = new global.Workflow(); + +const rest = new sn_ws.RESTMessageV2(); + +interface ScopedGlideRecord { + new (tableName: 'othertype'): OtherType; +} +interface OtherType extends ScopedGlideRecord { + someproperty: string; +} + +const grOther = new GlideRecord('othertype'); +grOther.someproperty = 'foo'; diff --git a/types/servicenow-london/test/Class.ts b/types/servicenow-london/test/Class.ts deleted file mode 100644 index f6d1c9f2b7..0000000000 --- a/types/servicenow-london/test/Class.ts +++ /dev/null @@ -1,11 +0,0 @@ -var NewInclude = Class.create(); - -NewInclude.prototype = { - initialize: function() {}, - - myFunction: function() { - //Put function code here - }, - - type: 'NewInclude' -}; diff --git a/types/servicenow-london/test/GlideDBFunctionBuilder.ts b/types/servicenow-london/test/GlideDBFunctionBuilder.ts deleted file mode 100644 index 0fc4b980e1..0000000000 --- a/types/servicenow-london/test/GlideDBFunctionBuilder.ts +++ /dev/null @@ -1,75 +0,0 @@ -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myAddingFunction = functionBuilder.add(); - myAddingFunction = functionBuilder.field('order'); - myAddingFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myAddingFunction = functionBuilder.add(); - myAddingFunction = functionBuilder.field('order'); - myAddingFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); - gs.info(func); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myConcatFunction = functionBuilder.concat(); - myConcatFunction = functionBuilder.field('short_description'); - myConcatFunction = functionBuilder.field('caller_id.name'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myDateDiffFunction = functionBuilder.datediff(); - myDateDiffFunction = functionBuilder.field('sys_updated_on'); - myDateDiffFunction = functionBuilder.field('opened_at'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var dayOfWeekFunction = functionBuilder.dayofweek(); - dayOfWeekFunction = functionBuilder.field('opened_at'); - dayOfWeekFunction = functionBuilder.constant('2'); - var func = functionBuilder.build(); - - var gr = new GlideRecord('incident'); - gr.addFunction(func); - gr.query(); - while (gr.next()) gs.info(gr.getValue(func)); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myDivideFunction = functionBuilder.divide(); - myDivideFunction = functionBuilder.field('order'); - myDivideFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myAddingFunction = functionBuilder.add(); - myAddingFunction = functionBuilder.field('order'); - myAddingFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myLengthFunction = functionBuilder.length(); - myLengthFunction = functionBuilder.field('short_description'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myMultiplyFunction = functionBuilder.multiply(); - myMultiplyFunction = functionBuilder.field('order'); - myMultiplyFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var mySubtractFunction = functionBuilder.subtract(); - mySubtractFunction = functionBuilder.field('order'); - mySubtractFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); -})(); diff --git a/types/servicenow-london/test/GlideDate.ts b/types/servicenow-london/test/GlideDate.ts deleted file mode 100644 index 1a4c2fd086..0000000000 --- a/types/servicenow-london/test/GlideDate.ts +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var gd = new GlideDate(); - gs.info(gd.getByFormat('dd-MM-yyyy')); - gs.info(gd.getDayOfMonthNoTZ()); - gs.info(gd.getDisplayValue()); - gs.info(gd.getDisplayValueInternal()); - gs.info(gd.getMonthNoTZ()); - gs.info(gd.getValue()); - gs.info(gd.getYearNoTZ()); - gd.setDisplayValue('2011-01-01'); - gd.setValue('2015-01-01'); - var sgd1 = new GlideDate(); - sgd1.setDisplayValue('2014-07-18'); - var sgd2 = new GlideDate(); - sgd2.setDisplayValue('2014-07-19'); - var duration = GlideDate.subtract(sgd1, sgd2); - gs.info(duration.getDisplayValue()); -})(); diff --git a/types/servicenow-london/test/GlideDateTime.ts b/types/servicenow-london/test/GlideDateTime.ts deleted file mode 100644 index e3396f268d..0000000000 --- a/types/servicenow-london/test/GlideDateTime.ts +++ /dev/null @@ -1,100 +0,0 @@ -(function() { - var gdt = new GlideDateTime('2011-08-31 08:00:00'); - var gtime1 = new GlideTime(); - gtime1.setValue('00:00:20'); - gdt.add(gtime1); - var gtime2 = gdt.getTime(); - gs.info(gtime2.getByFormat('hh:mm:ss')); - gdt.add(10); - var start = new GlideDateTime('2011-01-01 12:00:00'); - var end = new GlideDateTime(start); - gdt.addDaysLocalTime(-1); - gdt.addDaysUTC(-1); - gdt.addMonthsLocalTime(2); - gdt.addMonthsUTC(2); - gdt.addSeconds(1000); - gdt.addWeeksLocalTime(-1); - gdt.addWeeksUTC(-1); - gdt.addYearsLocalTime(1); - gdt.addYearsUTC(1); - var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); - var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); - gs.info(gdt1.after(gdt2)); - gs.info(gdt1.before(gdt2)); - var initDate = new GlideDateTime('2011-08-01 12:00:00'); - var compDate1 = new GlideDateTime('2011-08-01 12:00:00'); - var compDate2 = new GlideDateTime('2011-07-31 12:00:00'); - var compDate3 = new GlideDateTime('2011-08-04 16:00:00'); - gs.info(initDate.compareTo(compDate1)); // Equals (0) - gs.info(initDate.compareTo(compDate2)); // initDate is after compDate2 (1) - gs.info(initDate.compareTo(compDate3)); // initDate is before compDate3 (-1) - gs.info(gdt.equals('2011-09-30 00:12:01')); - gs.info(gdt.getDate()); - gs.info(gdt.getValue()); - gs.info(gdt.getDayOfMonthLocalTime()); - gs.info(gdt.getDayOfMonthUTC()); - gs.info(gdt.getDayOfWeekLocalTime()); - gs.info(gdt.getDayOfWeekLocalTime()); - gs.info(gdt.getDaysInMonthLocalTime()); - gs.info(gdt.getDaysInMonthUTC()); - gs.info(gdt.getDisplayValue()); - gs.info(gdt.getDisplayValueInternal()); //uses current user session time zone (US/Pacific) - gs.info(gdt.getDSTOffset()); //uses current user session time zone (US/Pacific) - gdt.setDisplayValue('2011-aa-01 00:00:00'); - gs.info(gdt.getErrorMsg()); // Could not parse DateTime: 2011-aa-01 00:00:00 - gs.info(gdt.getLocalDate()); - var gt = gdt.getLocalTime(); - gs.info('local time is ' + gt.getByFormat('hh:mm:ss')); - gs.info(gdt.getMonthLocalTime()); - gs.info(gdt.getMonthUTC()); - gs.info(gdt.getNumericValue()); - var gt = gdt.getTime(); - gs.info(gt.getByFormat('hh:mm:ss')); - gdt.getLocalTime(); // PST local time - gs.info(gdt.getTZOffset()); - gs.info(gdt.getValue()); - gs.info(gdt.getWeekOfYearLocalTime()); - gs.info(gdt.getWeekOfYearUTC()); - gs.info(gdt.getYearLocalTime()); - gs.info(gdt.getYearUTC()); - gs.info(gdt.hasDate()); - gs.info(gdt.isDST()); //true - gdt.setDisplayValue('2011-aa-01 00:00:00'); - gs.info(gdt.isValid()); - var gdt1 = new GlideDateTime('2016-05-09 10:11:12'); - var gdt2 = new GlideDateTime('2017-06-12 15:11:12'); - gs.info(gdt1.onOrAfter(gdt2)); - gs.info(gdt1.onOrBefore(gdt2)); - gdt.setDayOfMonthLocalTime(9); - gs.info(gdt.getDayOfMonthLocalTime()); - gdt.setDayOfMonthUTC(9); - gs.info(gdt.getDayOfMonthUTC()); - gdt.setDisplayValue('2014-01-01 12:00:00'); - gdt.setDisplayValue('20-5-2011 12:00:00', 'dd-MM-yyyy HH:mm:ss'); - gdt.setDisplayValueInternal('2014-01-01 12:00:00'); - var dt1 = new GlideDateTime('2011-01-01 12:00:00'); - var dt2 = new GlideDateTime('2011-02-02 08:00:00'); - dt1.setGlideDateTime(dt2); - gdt.setMonthLocalTime(1); - gs.info(gdt.getMonthLocalTime()); - gdt.setMonthUTC(1); - gs.info(gdt.getMonthUTC()); - gdt.setValue('2011-02-02 08:00:00'); // value set = 2011-02-02 08:00:00 - gdt.setValueUTC('15-02-2011 08:00:00', 'dd-MM-yyyy HH:mm:ss'); - gdt.setYearLocalTime(2013); - gs.info(gdt.getYearLocalTime()); - gdt.setYearUTC(2013); - gs.info(gdt.getYearUTC()); - var gdt1 = new GlideDateTime('2011-08-28 09:00:00'); - var gdt2 = new GlideDateTime('2011-08-31 08:00:00'); - var dur = GlideDateTime.subtract(gdt1, gdt2); //the difference between gdt1 and gdt2 - gs.info(dur.getDisplayValue()); - var gtime1 = new GlideTime(); - gtime1.setValue('00:00:20'); - gdt.subtract(gtime1); - var gtime2 = gdt.getTime(); - gs.info(gtime2.getByFormat('hh:mm:ss')); - var gdt = new GlideDateTime('2011-12-07 08:00:00'); - gdt.subtract(1000); - gs.info(gdt.toString()); -})(); diff --git a/types/servicenow-london/test/GlideDuration.ts b/types/servicenow-london/test/GlideDuration.ts deleted file mode 100644 index f217d74e74..0000000000 --- a/types/servicenow-london/test/GlideDuration.ts +++ /dev/null @@ -1,46 +0,0 @@ -(function() { - var duration = new GlideDuration('3 12:00:00'); - var duration2 = new GlideDuration('3:00:00'); - var answer = duration.add(duration2); - gs.info(answer.getDisplayValue()); -})(); -(function() { - var dur = new GlideDuration('3 22:00:00'); - gs.info(dur.getByFormat('HH:mm')); -})(); -(function() { - var dur = new GlideDuration('3 12:00:00'); - gs.info(dur.getDayPart()); -})(); -(function() { - var dur = new GlideDuration('3 12:00:00'); - gs.info(dur.getDisplayValue()); -})(); -(function() { - var dur = new GlideDuration('3 12:00:00'); - gs.info(dur.getDurationValue()); -})(); -(function() { - var dur = new GlideDuration('3 11:00:00'); - gs.info(dur.getRoundedDayPart()); -})(); -(function() { - var dur = new GlideDuration('3 12:00:00'); - gs.info(dur.getValue()); -})(); -(function() { - var dur = new GlideDuration(); - dur.setDisplayValue('3 08:00:00'); - gs.info(dur.getDisplayValue()); -})(); -(function() { - var dur = new GlideDuration(); - dur.setValue('1970-01-05 08:00:00'); // sets internal DateTime value. The String will be parsed into a GlideDateTime object. - gs.info(dur.getDisplayValue()); -})(); -(function() { - var duration = new GlideDuration('3 12:00:00'); - var duration2 = new GlideDuration('3:00:00'); - var answer = duration.subtract(duration2); - gs.info(answer.getDisplayValue()); -})(); diff --git a/types/servicenow-london/test/GlideEmailOutbound.ts b/types/servicenow-london/test/GlideEmailOutbound.ts deleted file mode 100644 index 969e16255f..0000000000 --- a/types/servicenow-london/test/GlideEmailOutbound.ts +++ /dev/null @@ -1,21 +0,0 @@ -(function() { - email.addAddress('cc', 'joe.employee@something.com'); -})(); -(function() { - email.addAddress('bcc', 'joe.employee@something.com', 'dudley rocks'); -})(); -(function() { - var watermark = email.getWatermark(); -})(); -(function() { - email.setBody('Dear Sir, ...'); -})(); -(function() { - email.setFrom('joe.employee@something.com'); -})(); -(function() { - email.setReplyTo('joe.employee@something.com'); -})(); -(function() { - email.setSubject('Important Issues to discuss'); -})(); diff --git a/types/servicenow-london/test/GlideFilter.ts b/types/servicenow-london/test/GlideFilter.ts deleted file mode 100644 index ff0348c71e..0000000000 --- a/types/servicenow-london/test/GlideFilter.ts +++ /dev/null @@ -1,10 +0,0 @@ -(function() { - var rec = new GlideRecord('incident'); - rec.query(); - var bool = true; - - while (rec.next()) { - bool = GlideFilter.checkRecord(rec, 'active=true'); - gs.info('number ' + rec.number + ' is ' + bool); - } -})(); diff --git a/types/servicenow-london/test/GlideLocale.ts b/types/servicenow-london/test/GlideLocale.ts deleted file mode 100644 index 831d035919..0000000000 --- a/types/servicenow-london/test/GlideLocale.ts +++ /dev/null @@ -1,15 +0,0 @@ -(function() { - var locale = GlideLocale.get(); -})(); -(function() { - var locale = GlideLocale.get(); - var decimalSeparator = locale.getDecimalSeparator(); - gs.info('The decimal separator is ' + decimalSeparator); - // The decimal separator is . -})(); -(function() { - var locale = GlideLocale.get(); - var groupingSeparator = locale.getGroupingSeparator(); - gs.info('The grouping separator is ' + groupingSeparator); - // The grouping separator is , -})(); diff --git a/types/servicenow-london/test/GlidePluginManager.ts b/types/servicenow-london/test/GlidePluginManager.ts deleted file mode 100644 index ca040d31b2..0000000000 --- a/types/servicenow-london/test/GlidePluginManager.ts +++ /dev/null @@ -1,18 +0,0 @@ -(function() { - var gr = new GlideRecord('sys_plugins'); - var queryString = 'active=0^ORactive=1'; - gr.addEncodedQuery(queryString); - gr.query(); - var pMgr = new GlidePluginManager(); - - while (gr.next()) { - var name = gr.getValue('name'); - var pID = gr.getValue('source'); - var isActive = pMgr.isActive(pID); - if (isActive) gs.info('The plugin ' + name + ' is active'); - } - // The plugin Country Lookup Data is active - // The plugin Database Replication is active - // The plugin REST API Provider is active - // The plugin Ten Cool Things is active ... -})(); diff --git a/types/servicenow-london/test/GlideSchedule.ts b/types/servicenow-london/test/GlideSchedule.ts deleted file mode 100644 index ada8aeaf6d..0000000000 --- a/types/servicenow-london/test/GlideSchedule.ts +++ /dev/null @@ -1,62 +0,0 @@ -(function() { - var startDate = new GlideDateTime('2014-01-02'); - var days = 2; - var dur = new GlideDuration(60 * 60 * 24 * 1000 * days); - var schedule = new GlideSchedule(); - var end = schedule.add(startDate, dur); - gs.info(end); -})(); -(function() { - var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828', 'US/Pacific'); -})(); -(function() { - var startDate = new GlideDateTime('2014-10-16 02:00:00'); - var endDate = new GlideDateTime('2014-10-18 04:00:00'); - var schedule = new GlideSchedule(); - - schedule.load('090eecae0a0a0b260077e1dfa71da828'); // loads "8-5 weekdays excluding holidays" schedule - var duration = schedule.duration(startDate, endDate); - gs.info(duration.getDurationValue()); // gets the elapsed time in schedule -})(); -(function() { - var sys_id = '04e664654a36232701a2247dcd8fc4cf'; // sys_id for "Application" schedule record - var sched = new GlideSchedule(sys_id); - gs.info(sched.getName()); -})(); -(function() { - var g = new GlideRecord('cmn_schedule'); - g.addQuery('type', 'blackout'); - g.query(); - if (g.next()) { - var sched = new GlideSchedule(g.sys_id); - var d = new GlideDateTime(); - d.setDisplayValue('2007-09-18 12:00:00'); - if (sched.isInSchedule(d)) gs.info('Is in the schedule'); - else gs.info('Is NOT in the schedule'); - } -})(); -(function() { - var g = new GlideRecord('cmn_schedule'); - g.addQuery('type', 'blackout'); - g.query(); - if (g.next()) { - var sched = new GlideSchedule(g.sys_id); - var d = new GlideDateTime(); - d.setDisplayValue('2007-09-18 12:00:00'); - if (sched.isValid()) gs.info('Is valid'); - else gs.info('Is not valid'); - } -})(); -(function() { - var x = new GlideSchedule(); - x.load('08fcd0830a0a0b2600079f56b1adb9ae'); -})(); -(function() { - var schedule = new GlideSchedule(); - schedule.setTimeZone('US/Pacific'); -})(); -(function() { - var startDate = new GlideDateTime('2014-10-25 08:00:00'); - var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae', 'UTC'); - gs.info(glideSchedule.whenNext(startDate)); -})(); diff --git a/types/servicenow-london/test/GlideScopedEvaluator.ts b/types/servicenow-london/test/GlideScopedEvaluator.ts deleted file mode 100644 index 4a3745ee11..0000000000 --- a/types/servicenow-london/test/GlideScopedEvaluator.ts +++ /dev/null @@ -1,34 +0,0 @@ -(function() { - // For this example, we created a table: "x_app_table" - // with two columns: "short_description", "test_script" - // "test_script" will store the script to be evaluated by GlideScopedEvaluator. - var gr = new GlideRecord('x_app_table'); - gr.short_description = 'Testing GlideScopedEvaluator'; - gr.test_script = "gs.getUser().getName() + ' says ' + greeting; "; - gr.insert(); - - // setup variables to be used by the script - var vars = { greeting: 'hello' }; - - //Evaluate the script from the field - var evaluator = new GlideScopedEvaluator(); - gs.info(evaluator.evaluateScript(gr, 'test_script', vars)); - // ${user_name} says hello -})(); -(function() { - //setting up a record that contains the script to be executed. - var gr = new GlideRecord('x_app_table'); - gr.short_description = 'Calculate Addition'; - gr.test_script = 'result = x + y'; - gr.insert(); - - var evaluator = new GlideScopedEvaluator(); - evaluator.putVariable('x', 100); - evaluator.putVariable('y', 200); - evaluator.putVariable('result', null); - - // Now retrieve the result - evaluator.evaluateScript(gr, 'test_script', null); - gs.info(evaluator.getVariable('result')); - // 300 -})(); diff --git a/types/servicenow-london/test/GlideScriptedProcessor.ts b/types/servicenow-london/test/GlideScriptedProcessor.ts deleted file mode 100644 index 470458074c..0000000000 --- a/types/servicenow-london/test/GlideScriptedProcessor.ts +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - //Do whatever processing you need and redirect to the homepage - g_processor.redirect('/navpage.do'); -})(); -(function() { - var map = { key1: 'value1', key2: 'value2' }; - g_processor.writeJSON(map); -})(); -(function() { - var name = g_request.getParameter('name'); - g_processor.writeOutput('text/plain', 'Hello ' + name); -})(); -(function() { - var name = g_request.getParameter('name'); - g_processor.writeOutput('Hello ' + name); -})(); diff --git a/types/servicenow-london/test/GlideSecureRandomUtil.ts b/types/servicenow-london/test/GlideSecureRandomUtil.ts deleted file mode 100644 index 249f502af7..0000000000 --- a/types/servicenow-london/test/GlideSecureRandomUtil.ts +++ /dev/null @@ -1,12 +0,0 @@ -(function() { - gs.info(GlideSecureRandomUtil.getSecureRandomInt()); -})(); -(function() { - gs.info(GlideSecureRandomUtil.getSecureRandomIntBound(100)); -})(); -(function() { - gs.info(GlideSecureRandomUtil.getSecureRandomLong()); -})(); -(function() { - gs.info(GlideSecureRandomUtil.getSecureRandomString(12)); -})(); diff --git a/types/servicenow-london/test/GlideServletRequest.ts b/types/servicenow-london/test/GlideServletRequest.ts deleted file mode 100644 index 0eae56fd0c..0000000000 --- a/types/servicenow-london/test/GlideServletRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var contentType = g_request.getContentType(); -})(); -(function() { - var headerValue = g_request.getHeader('host'); - // demonightlyus.service-now.com -})(); -(function() { - var headerList = g_request.getHeaderNames(); - // host,connection,cache-control,authorization,accept,user-agent,accept-encoding, - // accept-language, cookie,x-forwarded-proto,x-forwarded-host,x-forwarded-for -})(); -(function() { - var headerValue = g_request.getHeaders('host'); - // demonightlyus.service-now.com -})(); -(function() { - var name = g_request.getParameter('x_snc_custom_x_snc_name'); -})(); -(function() { - var paramList = g_request.getParameterNames(); -})(); -(function() { - var daString = g_request.getQueryString(); - g_processor.writeOutput('The query string is: ' + daString); -})(); diff --git a/types/servicenow-london/test/GlideServletResponse.ts b/types/servicenow-london/test/GlideServletResponse.ts deleted file mode 100644 index c0cfc5a082..0000000000 --- a/types/servicenow-london/test/GlideServletResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -(function() { - g_response.setContentType('text/html;charset=UTF-8'); -})(); -(function() { - g_response.setHeader('host', 'demonightlyus.service-now.com'); -})(); -(function() { - // set the status to okay - g_response.setStatus(200); -})(); diff --git a/types/servicenow-london/test/GlideSession.ts b/types/servicenow-london/test/GlideSession.ts deleted file mode 100644 index fd702606b3..0000000000 --- a/types/servicenow-london/test/GlideSession.ts +++ /dev/null @@ -1,64 +0,0 @@ -(function() { - var session = gs.getSession(); - session.putClientData('test1', 'Harry'); - var clientData = session.getClientData('test1'); - gs.info(clientData); - // Harry -})(); -(function() { - var session = gs.getSession(); - var addr = session.getClientIP(); - gs.info(addr); -})(); -(function() { - var session = gs.getSession(); - var appID = session.getCurrentApplicationId(); - gs.info(appID); - // ce05b9f32b840200c5244f74b4da1501 -})(); -(function() { - var session = gs.getSession(); - var language = session.getLanguage(); - gs.info(language); - // en -})(); -(function() { - var session = gs.getSession(); - var token = session.getSessionToken(); - gs.info(token); - // 4284b5372b840200c5244f74b4da15f2c3476cf7fcb6572afa4ef9d5e6d307a5fd9e1da7 -})(); -(function() { - var session = gs.getSession(); - var zoneName = session.getTimeZoneName(); - gs.info(zoneName); - // US/Pacific -})(); -(function() { - var session = gs.getSession(); - var URL = session.getUrlOnStack(); - gs.info(URL); - // sys_app.do?sys_id=ce05b9f32b840200c5244f74b4da1501&sysparm_goto_url=sys_app.do - // %3Fsys_id%3Dce05b9f32b840200c5244f74b4da1501 -})(); -(function() { - var isImpersonator = gs.getSession().isImpersonating(); - gs.info(isImpersonator); -})(); -(function() { - var interActive = gs.getSession().isInteractive(); - gs.info(interActive); -})(); -(function() { - var session = gs.getSession(); - var loggedIn = session.isLoggedIn(); - gs.info(loggedIn); - // true -})(); -(function() { - var session = gs.getSession(); - session.putClientData('test1', 'Harry'); - var clientData = session.getClientData('test1'); - gs.info(clientData); - // Harry -})(); diff --git a/types/servicenow-london/test/GlideStringUtil.ts b/types/servicenow-london/test/GlideStringUtil.ts deleted file mode 100644 index 1cf7a3ab6b..0000000000 --- a/types/servicenow-london/test/GlideStringUtil.ts +++ /dev/null @@ -1,85 +0,0 @@ -(function() { - var filename = '../../../../../../etc/passwd'; - var cleanFilename = GlideStringUtil.dotToUnderBar(filename); - gs.info(cleanFilename); - // __/__/__/__/__/__/etc/passwd -})(); -(function() { - var mystring = "let's escape some quotes"; - var escapeQuote = GlideStringUtil.escapeAllQuotes(mystring); - gs.info(escapeQuote); - // lets escape some quotes -})(); -(function() { - var mystring = ' string \n to escape'; - var escapedString = GlideStringUtil.escapeForHomePage(mystring); - gs.info(escapedString); - // %3ctest%3e string \n to escape -})(); -(function() { - var mydata = '"<>&'; - mydata = GlideStringUtil.escapeHTML(mydata); - gs.info(mydata); - // "<>& -})(); -(function() { - var mystring = 'test \x09 non \x00 printable \x07 chars'; - var escapedString = GlideStringUtil.escapeNonPrintable(mystring); - gs.info(escapedString); - // test \t non \u0000 printable \u0007 chars -})(); -(function() { - var myquery = 'test^Test'; - var escapedQuery = GlideStringUtil.escapeQueryTermSeparator(myquery); - gs.info(escapedQuery); - // test^^Test -})(); -(function() { - var mystring = "let's try escapeTicks"; - var escaped = GlideStringUtil.escapeTicks(mystring); - gs.info(escaped); - // let\'s try escapeTicks -})(); -(function() { - var mydata = '&'; - var htmlvalue = GlideStringUtil.getHTMLValue(mydata); - gs.info(htmlvalue); - // & -})(); -(function() { - var mystring = '123 test 456 String 789 cleaning'; - var onlyNumeric = GlideStringUtil.getNumeric(mystring); - gs.info(onlyNumeric); - // 123456789 -})(); -(function() { - // (adding a "*" to corrupt the base64 format) - var base64 = 'GethdTYehdtshetB*'; - var isValid = GlideStringUtil.isBase64(base64); - gs.info(isValid); - // false -})(); -(function() { - var sysID = '62826bf03710200044e0bfc8bcbe5df1'; - var isElig = GlideStringUtil.isEligibleSysID(sysID); - gs.info(isElig); - // true -})(); -(function() { - var mystring = 'new line break \n, this is after the break'; - var replaceNewLine = GlideStringUtil.newLinesToBreaks(mystring); - gs.info(replaceNewLine); - // new line break
, this is after the break -})(); -(function() { - var mystring = 'test with \n (new line) and \t (tabulation)'; - var normalizedString = GlideStringUtil.normalizeWhitespace(mystring); - gs.info(normalizedString); - // test with (new line) and (tabulation) -})(); -(function() { - var mydata = '"<>&'; - var unescaped = GlideStringUtil.unescapeHTML(mydata); - gs.info(unescaped); - // "<>& -})(); diff --git a/types/servicenow-london/test/GlideSysAttachment.ts b/types/servicenow-london/test/GlideSysAttachment.ts deleted file mode 100644 index 0ffdd02fcb..0000000000 --- a/types/servicenow-london/test/GlideSysAttachment.ts +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/types/servicenow-london/test/GlideSystem.ts b/types/servicenow-london/test/GlideSystem.ts deleted file mode 100644 index 0458978982..0000000000 --- a/types/servicenow-london/test/GlideSystem.ts +++ /dev/null @@ -1,211 +0,0 @@ -(function() { - gs.addErrorMessage('Invalid account'); -})(); -(function() { - if (!current.u_date1.nil() && !current.u_date2.nil()) { - var start = current.u_date1.getGlideObject().getNumericValue(); - var end = current.u_date2.getGlideObject().getNumericValue(); - if (start > end) { - gs.addInfoMessage('start must be before end'); - current.u_date1.setError('start must be before end'); - current.setAbortAction(true); - } - } -})(); -(function() { - function contractNoticeDue() { - var gr = new GlideRecord('contract'); - gr.addQuery('u_contract_status', 'Active'); - gr.query(); - while (gr.next()) { - if (gr.u_termination_date <= gs.daysAgo(-90) && gr.u_contract_duration == 'Long') { - gr.u_contract_status = 'In review'; - } else if ( - gr.u_termination_date <= gs.daysAgo(-50) && - gr.u_contract_duration == 'Medium' - ) { - gr.u_contract_status = 'In review'; - } else if ( - gr.u_termination_date <= gs.daysAgo(-10) && - gr.u_contract_duration == 'Short' - ) { - gr.u_contract_status = 'In review'; - } - } - gr.update(); - } -})(); -(function() { - var gr = new GlideRecord('sysapproval_approver'); - gr.addQuery('state', 'requested'); - gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(5)); - gr.query(); -})(); -(function() { - gs.debug('This is a debug message'); - var myFirstName = 'Abel'; - var myLastName = 'Tuter'; - gs.debug('This is a debug message from {0}.{1}', myFirstName, myLastName); -})(); -(function() { - gs.error('This is an error message'); - var myFirstName = 'Abel'; - var myLastName = 'Tuter'; - gs.error('This is an error message from {0}.{1}', myFirstName, myLastName); -})(); -(function() { - if (current.operation() != 'insert' && current.comments.changes()) { - gs.eventQueue('incident.commented', current, gs.getUserID(), gs.getUserName()); - } -})(); -(function() { - var personalId = gs.generateGUID(); - gs.info(personalId); - // af770511ff013100e04bfffffffffff6 -})(); -(function() { - return gs.getCallerScopeName(); -})(); -(function() { - var verStr = gs.getCssCacheVersionString(); - gs.info(verStr); - // _d82979516f0171005be8883e6b3ee4cf&theme= -})(); -(function() { - var currentId = gs.getCurrentApplicationId(); - gs.info(currentId); - // 04936cb16f30b1005be8883e6b3ee4e0 -})(); -(function() { - var currentScope = gs.getCurrentScopeName(); - gs.info(currentScope); -})(); -(function() { - var myMessage = gs.getEscapedMessage('Hello {0}', ['mom']); -})(); -(function() { - var attachment_link = gs.getProperty('glide.servlet.uri'); - gs.info(attachment_link); - // https://instance.service-now.com/ -})(); -(function() { - if (!gs.hasRole('admin') && !gs.hasRole('user_admin') && gs.getSession().isInteractive()) { - current.addQuery('active', 'true'); - } -})(); -(function() { - var myUserObject = gs.getSessionID(); - gs.info(myUserObject); -})(); -(function() { - gs.info(gs.getTimeZoneName()); -})(); -(function() { - gs.info(gs.getUrlOnStack()); -})(); -(function() { - var myUserObject = gs.getUser(); -})(); -(function() { - gs.info(gs.getUserDisplayName()); -})(); -(function() { - gs.info(gs.getUserID()); -})(); -(function() { - gs.info(gs.getUserName()); -})(); -(function() { - if (!gs.hasRole('admin') && !gs.hasRole('groups_admin') && gs.getSession().isInteractive()) { - var qc = current.addQuery('u_hidden', '!=', 'true'); //cannot see hidden groups... - qc.addOrCondition('sys_id', 'javascript:getMyGroups()'); //...unless in the hidden group - gs.info('User has admin and groups admin roles'); - } else { - gs.info('User does not have both admin and groups admin roles'); - } -})(); -(function() { - if (current.operation() == 'insert') { - // If no due date was specified, calculate a default - if (current.due_date == '') { - if (current.urgency == '1') { - // Set due date to 4 hours ahead of current time - current.due_date = gs.hoursAgo(-4); - } - - if (current.urgency == '2') { - // Set due date to 2 days ahead of current time - current.due_date = gs.daysAgo(-2); - } - - if (current.urgency == '3') { - // Set due date to 7 days ahead of current time - current.due_date = gs.daysAgo(-7); - } - } - } -})(); -(function() { - gs.include('PrototypeServer'); -})(); -(function() { - gs.info('This is an info message'); - var myFirstName = 'Abel'; - var myLastName = 'Tuter'; - gs.info('This is an info message from {0}.{1}', myFirstName, myLastName); -})(); -(function() { - gs.debug('This is a log message'); - var myFirstName = 'Abel'; - var myLastName = 'Tuter'; - gs.debug('This is a log message from {0}.{1}', myFirstName, myLastName); - gs.info(gs.isDebugging()); -})(); -(function() { - if (!gs.hasRole('admin') && gs.getSession().isInteractive()) { - var qc1 = current.addQuery('u_group', ''); - var gra = new GlideRecord('sys_user_grmember'); - gra.addQuery('user', gs.getUserID()); - gra.query(); - while (gra.next()) { - qc1.addOrCondition('u_group', gra.group); - } - } -})(); -(function() { - gs.info(gs.isLoggedIn()); -})(); -(function() { - if (gs.isMobile()) gs.info('submitted from mobile UI'); - else gs.info('NOT submitted from mobile UI'); -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gs.nil(gr)); -})(); -(function() { - gs.setProperty('glide.foo', 'bar', 'foo'); - gs.info(gs.getProperty('glide.foo')); -})(); -(function() { - gs.setRedirect( - 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=d41ce5bac611227a0167f4bf8109bf70&sysparm_user=' + - current.sys_id + - '&sysparm_email=' + - current.email - ); -})(); -(function() { - gs.info(gs.tableExists('incident')); -})(); -(function() { - gs.warn('This is a warning'); - var myFirstName = 'Abel'; - var myLastName = 'Tuter'; - gs.warn('This is a warning from {0}.{1}', myFirstName, myLastName); -})(); -(function() { - var xmlString = 'value'; - var jsonObject = gs.xmlToJSON(xmlString); - gs.info(jsonObject); -})(); diff --git a/types/servicenow-london/test/GlideTime.ts b/types/servicenow-london/test/GlideTime.ts deleted file mode 100644 index 805e4da23a..0000000000 --- a/types/servicenow-london/test/GlideTime.ts +++ /dev/null @@ -1,46 +0,0 @@ -(function() { - var gt = new GlideTime(); - gs.info(gt.getDisplayValue()); -})(); -(function() { - var gt = new GlideTime(10000); - gs.info(gt.getDisplayValue()); -})(); -(function() { - var gt = new GlideTime(); - gt.setValue('12:00:00'); - gs.info(gt.getByFormat('HH:mm')); -})(); -(function() { - var gt = new GlideTime(); - gt.setDisplayValue('12:00:00'); // User Time Zone - gs.info(gt.getDisplayValue()); // User Time Zone -})(); -(function() { - var gt = new GlideTime(); - gt.setValue('01:00:00'); //Internal Time Zone , UTC - gs.info(gt.getDisplayValueInternal()); //User Time Zone -})(); -(function() { - var gt = new GlideTime(); - gs.info(gt.getValue()); // Internal Time Zone, UTC -})(); -(function() { - var gt = new GlideTime(); - gt.setDisplayValue('01:00:00'); // User Time Zone - gs.info(gt.getDisplayValueInternal()); // User Time Zone -})(); -(function() { - var gt = new GlideTime(); - gt.setValue('01:00:00'); //Internal Time Zone, UTC - gs.info('time is ' + gt.getByFormat('hh:mm:ss')); -})(); -(function() { - var gd1 = new GlideTime(); - gd1.setDisplayValue('09:00:00'); - var gd2 = new GlideTime(); - gd2.setDisplayValue('09:10:00'); - - var dur = GlideDate.subtract(gd1, gd2); //the difference between gdt1 and gdt2 - gs.info(dur.getDisplayValue()); -})(); diff --git a/types/servicenow-london/test/GlideUser.ts b/types/servicenow-london/test/GlideUser.ts deleted file mode 100644 index c554843db3..0000000000 --- a/types/servicenow-london/test/GlideUser.ts +++ /dev/null @@ -1,59 +0,0 @@ -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getCompanyID()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getDisplayName()); -})(); -(function() { - var domain = new GlideRecord('domain'); - domain.get(gs.getUser().getDomainID()); - gs.info(domain.name); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getEmail()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getFirstName()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getID()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getLastName()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getName()); -})(); -(function() { - var currentUser = gs.getUser(); - currentUser.savePreference('myPref', 'red'); - gs.info(currentUser.getPreference('myPref')); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getRoles()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.getUserRoles()); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.hasRole('admin')); -})(); -(function() { - var currentUser = gs.getUser(); - gs.info(currentUser.isMemberOf('Capacity Mgmt')); -})(); -(function() { - var currentUser = gs.getUser(); - currentUser.savePreference('myPref', 'red'); - gs.info(currentUser.getPreference('myPref')); -})(); diff --git a/types/servicenow-london/test/RESTAPIRequest.ts b/types/servicenow-london/test/RESTAPIRequest.ts deleted file mode 100644 index 14ec7ef8e3..0000000000 --- a/types/servicenow-london/test/RESTAPIRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -function testRESTAPIRequest(request: sn_ws.RESTAPIRequest) { - var entry; - var id; - var requestBody = request.body; - var requestData = requestBody.data; - if (requestData instanceof Array) { - entry = requestData[0].name; - id = requestData[0].id; - } else { - entry = requestData.name; - id = requestData.id; - } - - var requestStream = requestBody.dataStream; - var requestString = requestBody.dataString; - requestBody.hasNext(); - requestBody.hasNext(); - var requestEntry = requestBody.nextEntry(); - - var name = requestEntry.name; - requestEntry = requestBody.nextEntry(); -} diff --git a/types/servicenow-london/test/RESTAPIRequestBody.ts b/types/servicenow-london/test/RESTAPIRequestBody.ts deleted file mode 100644 index 6f4120d55f..0000000000 --- a/types/servicenow-london/test/RESTAPIRequestBody.ts +++ /dev/null @@ -1,33 +0,0 @@ -function testRESTAPIRequestBody(request: sn_ws.RESTAPIRequest) { - var requestBody = request.body; - // Returns instance of RESTAPIRequestBody - - var headers = request.headers; - var acceptHeader = headers.Accept; - var myCustomHeader = headers.myCustom; - var specialHeader = headers['special - header']; - var pathParams = request.pathParams; - var tableName = pathParams.tableName; - // "myApp_table" - - var id = pathParams.id; - // "1234" - - var queryParams = request.queryParams; - var isActiveQuery = queryParams.active; - // false - - var nameQueryVal = queryParams.name; - // "now" - - var query = request.queryString; - // "active=false&name=now" - - var query2 = request.uri; - // "api/now/table/myTable" - - var query3 = request.url; - // "https://instance.service-now.com/api/now/table/myTable?active=false&name=now" - - var acceptHeader = request.getHeader('accept'); -} diff --git a/types/servicenow-london/test/RESTAPIResponse.ts b/types/servicenow-london/test/RESTAPIResponse.ts deleted file mode 100644 index 9938141393..0000000000 --- a/types/servicenow-london/test/RESTAPIResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -function testRESTAPIResponse(response: sn_ws.RESTAPIResponse) { - response.setContentType('application/json'); - response.setStatus(200); - var writer = response.getStreamWriter(); - - var body: any = {}; - body.name = 'incident'; - body.number = '1234'; - body.caller = { id: 'user1' }; - response.setBody(body); - - var bodyArray = []; - body = {}; - body.name = 'incident'; - body.number = '1234'; - body.caller = { id: 'user1' }; - bodyArray.push(body); - response.setBody(bodyArray); - - response.setHeader('Location', ''); - - var headers: any = {}; - headers['X-Total-Count'] = 100; - headers.Location = 'https://instance.service-now.com/'; - response.setHeaders(headers); - - response.setStatus(200); -} diff --git a/types/servicenow-london/test/RESTAPIResponseStream.ts b/types/servicenow-london/test/RESTAPIResponseStream.ts deleted file mode 100644 index 75f30d88d3..0000000000 --- a/types/servicenow-london/test/RESTAPIResponseStream.ts +++ /dev/null @@ -1,17 +0,0 @@ -function testRESTAPIResponseStream(response: sn_ws.RESTAPIResponse, attachmentStream: any) { - response.setContentType('application/json'); - response.setStatus(200); - var writer = response.getStreamWriter(); - writer.writeStream(attachmentStream); - - response.setContentType('application/json'); - response.setStatus(200); - var writer = response.getStreamWriter(); - var body: any = { - name: 'user1', - id: 1234, - roles: [{ name: 'admin' }, { name: 'itil' }] - }; - writer.writeString("{'name':'user','id':'1234'}"); - writer.writeString(JSON.stringify(body)); -} diff --git a/types/servicenow-london/test/RESTMessageV2.ts b/types/servicenow-london/test/RESTMessageV2.ts deleted file mode 100644 index 4368c70293..0000000000 --- a/types/servicenow-london/test/RESTMessageV2.ts +++ /dev/null @@ -1,106 +0,0 @@ -(function() { - var sm = new sn_ws.RESTMessageV2('', 'get'); - var response = sm.execute(); - var response = sm.executeAsync(); - response.waitForResponse(60); - - var endpoint = sm.getEndpoint(); - var body = sm.getRequestBody(); - var header = sm.getRequestHeader('Accept'); - var headers = sm.getRequestHeaders(); - - sm.setBasicAuth('username', 'password'); - sm.setEccCorrelator('unique_identifier'); - sm.setEccParameter('source', 'http://very.long.endpoint.url'); - sm.setEndpoint('http://web.service.endpoint'); - sm.setHttpMethod('post'); - sm.setHttpTimeout(6000); - sm.setLogLevel('all'); - sm.setMIDServer('mid_server_name'); - sm.setMutualAuth('mutual_auth_profile_name'); - sm.setQueryParameter('sysparm_query', 'active=true^ORDERBYnumber^ORDERBYDESCcategory'); - sm.setRequestHeader('Accept', 'Application/json'); - sm.setStringParameter('s', 'NOW'); - sm.setStringParameterNoEscape('s', 'NOW'); - - var body = ''; - sm.setRequestBody(body); -})(); -(function sampleRESTMessageV2() { - try { - var request = new sn_ws.RESTMessageV2(); - request.setHttpMethod('get'); - - var attachment_sys_id = '', - tablename = 'incident', - recordSysId = '', - response, - httpResponseStatus, - filename = ''; - - //endpoint - ServiceNow REST Attachment API - request.setEndpoint( - 'https://.service-now.com/api/now/attachment/' + - attachment_sys_id + - '/file' - ); - request.setBasicAuth('', ''); - - //RESTMessageV2 - saveResponseBodyAsAttachment(String tableName, String recordSysId, String fileName) - request.saveResponseBodyAsAttachment(tablename, recordSysId, filename); - - response = request.execute(); - httpResponseStatus = response.getStatusCode(); - - gs.info(' http response status_code: ' + httpResponseStatus); - } catch (ex) { - var message = ex.getMessage(); - gs.info(message); - } -})(); -(function() { - var requestBody; - var response; - var responseBody; - var status; - var sm; - try { - // Might throw exception if message doesn't exist or not visible due to scope. - sm = new sn_ws.RESTMessageV2('', 'get'); - - //set auth profile to an OAuth 2.0 profile record. - sm.setAuthenticationProfile('oauth2', '1234adsf123212131123qasdsf'); - - sm.setStringParameter('symbol', 'NOW'); - sm.setStringParameterNoEscape('xml_data', 'test'); - - //In milliseconds. Wait at most 10 seconds for response from http request. - sm.setHttpTimeout(10000); - //Might throw exception if http connection timed out or some issue - //with sending request itself because of encryption/decryption of password. - response = sm.execute(); - responseBody = response.haveError() ? response.getErrorMessage() : response.getBody(); - status = response.getStatusCode(); - } catch (ex) { - responseBody = ex.getMessage(); - status = '500'; - } finally { - requestBody = sm ? sm.getRequestBody() : null; - } -})(); -(function sampleRESTMessageV2() { - try { - var request = new sn_ws.RESTMessageV2(); - request.setHttpMethod('post'); - request.setEndpoint(''); - request.setRequestBodyFromAttachment(''); - - var response = request.execute(); - var httpResponseStatus = response.getStatusCode(); - - gs.info('http response status_code: ' + httpResponseStatus); - } catch (ex) { - var message = ex.getMessage(); - gs.info(message); - } -})(); diff --git a/types/servicenow-london/test/RESTResponseV2.ts b/types/servicenow-london/test/RESTResponseV2.ts deleted file mode 100644 index 79ede22cc4..0000000000 --- a/types/servicenow-london/test/RESTResponseV2.ts +++ /dev/null @@ -1,22 +0,0 @@ -(function() { - var sm = new sn_ws.RESTMessageV2('
', 'get'); - var response = sm.execute(); - var allHeaders = response.getAllHeaders(); - for (var header in allHeaders) { - gs.info(allHeaders[header].name + ': ' + allHeaders[header].value); - } - var cookies = response.getCookies(); - for (var i = 0; i < cookies.size(); i++) { - gs.info('cookie: ' + cookies.get(i)); - } - var responseBody = response.getBody(); - var errorCode = response.getErrorCode(); - var errorMsg = response.getErrorMessage(); - var headerVal = response.getHeader('Content-Type'); - var headers = response.getHeaders(); - var queryString = response.getQueryString(); - var statusCode = response.getStatusCode(); - var error = response.haveError(); - var response = sm.executeAsync(); - response.waitForResponse(60); -})(); diff --git a/types/servicenow-london/test/SOAPMessageV2.ts b/types/servicenow-london/test/SOAPMessageV2.ts deleted file mode 100644 index 5181a9be3b..0000000000 --- a/types/servicenow-london/test/SOAPMessageV2.ts +++ /dev/null @@ -1,28 +0,0 @@ -(function() { - var sm = new sn_ws.SOAPMessageV2(); - sm = new sn_ws.SOAPMessageV2('StockQuote', 'GetQuote'); - var response = sm.execute(); - response = sm.executeAsync(); - var endpoint = sm.getEndpoint(); - var requestBody = sm.getRequestBody(); - var header = sm.getRequestHeader('Accept'); - var requestHeaders = sm.getRequestHeaders(); - sm.setBasicAuth('username', 'password'); - sm.setEccCorrelator('unique_id'); - sm.setEccParameter('source', 'http://very.long.endpoint'); - sm.setEndpoint('http://web.service.endpoint'); - sm.setHttpTimeout(6000); - sm.setMutualAuth('auth_profile_name'); - var body = ''; - sm.setRequestBody(body); - sm.setRequestHeader('Accept', 'Application/json'); - sm.setSOAPAction('GetQuote'); - sm.setStringParameter('symbol', 'NOW'); - sm.setStringParameterNoEscape('symbol', 'NOW'); - sm.setWSSecurity( - '70d65e074f3812001f6eac118110c71a', - 'Quote keys', - 'UXr82cqX75Z7MaSa+EyjGA==', - 'ba969a074f3812001f6eac118110c76d' - ); -})(); diff --git a/types/servicenow-london/test/SOAPResponseV2.ts b/types/servicenow-london/test/SOAPResponseV2.ts deleted file mode 100644 index c7a4c181a3..0000000000 --- a/types/servicenow-london/test/SOAPResponseV2.ts +++ /dev/null @@ -1,20 +0,0 @@ -(function() { - var r = new sn_ws.SOAPMessageV2('', 'get'); - var response = r.execute(); - var allHeaders = response.getAllHeaders(); - for (var h in allHeaders) { - gs.info(allHeaders[h].name + ': ' + allHeaders[h].value); - } - var body = response.getBody(); - var cookies = response.getCookies(); - for (var i = 0; i < cookies.size(); i++) { - gs.info('cookie: ' + cookies.get(i)); - } - var errorCode = response.getErrorCode(); - var errorMsg = response.getErrorMessage(); - var headerVal = response.getHeader("Accept"); - var headers = response.getHeaders(); - var statusCode = response.getStatusCode(); - var error = response.haveError(); - response.waitForResponse(60); -})(); diff --git a/types/servicenow-london/test/ScopedElementDescriptor.ts b/types/servicenow-london/test/ScopedElementDescriptor.ts deleted file mode 100644 index a0da98ba85..0000000000 --- a/types/servicenow-london/test/ScopedElementDescriptor.ts +++ /dev/null @@ -1,19 +0,0 @@ -(function() { - var gr = new GlideRecord('incident'); - gr.query('priority', '1'); - var field = gr.getElement('priority'); - var ed = field.getED(); - - var s = ed.getAttachmentEncryptionType(); - s = ed.getEncryptionType(); - s = ed.getInternalType(); - s = ed.getLabel(); - var n = ed.getLength(); - s = ed.getName(); - s = ed.getPlural(); - var b = ed.hasAttachmentsEncrypted(); - b = ed.isAutoOrSysID(); - b = ed.isChoiceTable(); - b = ed.isEdgeEncrypted(); - b = ed.isVirtual(); -})(); diff --git a/types/servicenow-london/test/ScopedGlideElement.ts b/types/servicenow-london/test/ScopedGlideElement.ts deleted file mode 100644 index 8d749d848e..0000000000 --- a/types/servicenow-london/test/ScopedGlideElement.ts +++ /dev/null @@ -1,13 +0,0 @@ -(function() { - var gr = new GlideRecord('incident'); - var el = gr.getElement('active'); - var b = el.changes(); - b = el.changesFrom(true); - b = el.changesTo(false); - var s = el.getAttribute('tree_picker'); - var sa = el.getChoices(); - s = el.getChoiceValue(); - s = el.getDecryptedValue(); - s = el.getDisplayValue(); - var ed = el.getED(); -})(); diff --git a/types/servicenow-london/test/ScopedGlideRecord.ts b/types/servicenow-london/test/ScopedGlideRecord.ts deleted file mode 100644 index d2a2ed715a..0000000000 --- a/types/servicenow-london/test/ScopedGlideRecord.ts +++ /dev/null @@ -1,400 +0,0 @@ -interface ScopedGlideRecord { - new (tableName: 'othertype'): OtherType; -} -interface OtherType extends ScopedGlideRecord { - someproperty: string; -} -(function testMerging() { - var gr = new GlideRecord('othertype'); - gr.someproperty = 'foo'; -})(); -(function() { - var inc = new GlideRecord('incident'); - inc.addActiveQuery(); - inc.query(); -})(); -(function() { - var queryString = 'priority=1^ORpriority=2'; - var gr = new GlideRecord('incident'); - gr.addEncodedQuery(queryString); - gr.query(); - while (gr.next()) { - gs.addInfoMessage(gr.number); - } -})(); -(function() { - var functionBuilder = new GlideDBFunctionBuilder(); - var myAddingFunction = functionBuilder.add(); - myAddingFunction = functionBuilder.field('order'); - myAddingFunction = functionBuilder.field('priority'); - var func = functionBuilder.build(); - - var gr = new GlideRecord('incident'); - gr.addFunction(func); - gr.addQuery(func, '<', 5); - gr.query(); - while (gr.next()) gs.info(gr.getValue(func)); -})(); -(function() { - var prob = new GlideRecord('problem'); - prob.addJoinQuery('incident'); - prob.query(); -})(); -(function() { - // Look for Problem records that have associated Incident records - var gr = new GlideRecord('problem'); - var grSQ = gr.addJoinQuery('incident'); - - // Where the Problem records are "active=false" - gr.addQuery('active', 'false'); - - // And the Incident records are "active=true" - grSQ.addCondition('active', 'true'); - - // Query - gr.query(); - - // Iterate and output results - while (gr.next()) { - gs.info(gr.getValue('number')); - } -})(); -(function() { - var gr = new GlideRecord('problem'); - gr.addJoinQuery('incident', 'opened_by', 'caller_id'); - gr.query(); -})(); -(function() { - var target = new GlideRecord('incident'); - target.addNotNullQuery('short_description'); - target.query(); // Issue the query to the database to get all records where short_description is not null - while (target.next()) { - // add code here to process the incident record - } -})(); -(function() { - var target = new GlideRecord('incident'); - target.addNullQuery('short_description'); - target.query(); // Issue the query to the database to get all records where short_description is null - while (target.next()) { - // add code here to process the incident record - } -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.addQuery('active', true); - rec.query(); - while (rec.next()) { - rec.active = false; - gs.info('Active incident ' + rec.number + ' closed'); - rec.update(); - } -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.addQuery('active', true); - rec.addQuery('sys_created_on', '>', '2010-01-19 04:05:00'); - rec.query(); - while (rec.next()) { - rec.active = false; - gs.info('Active incident ' + rec.number + ' closed'); - rec.update(); - } -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.addQuery('number', 'IN', 'INC00001,INC00002'); - gr.query(); - while (gr.next()) { - //do something.... - } -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.addQuery('active=true'); - rec.query(); - while (rec.next()) { - rec.active = false; - gs.info('Active incident ' + rec.number + ' closed'); - rec.update(); - } -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gr.canCreate()); - gs.info(gr.canDelete()); - gs.info(gr.canRead()); - gs.info(gr.canWrite()); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.orderBy('number'); - gr.chooseWindow(2, 4); - gr.query(); - if (gr.next()) { - gs.info(gr.number + ' is within window'); - } -})(); -(function() { - var inc = new GlideRecord('incident'); - inc.get('17c90efb13418700cc36b1422244b05d'); - gs.info(inc.calendar_duration.dateNumericValue()); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.addQuery('active', 'false'); //to delete all inactive incidents - gr.deleteMultiple(); -})(); -(function() { - var gr = new GlideRecord('incident'); - //to delete one record - if (gr.get('99ebb4156fa831005be8883e6b3ee4b9')) { - gr.deleteRecord(); - } -})(); -(function() { - var grIncident = new GlideRecord('incident'); - var returnValue = grIncident.get('99ebb4156fa831005be8883e6b3ee4b9'); - gs.info(returnValue); // logs true or false - gs.info(grIncident.number); // logs Incident Number -})(); -(function() { - var grIncident = new GlideRecord('incident'); - var returnValue = grIncident.get('caller_id.name', 'Sylivia Wayland'); - gs.info(returnValue); // logs true or false - gs.info(grIncident.number); // logs Incident Number -})(); -doit(); -function doit() { - var gr = new GlideRecord('sys_user'); - gr.query('user_name', 'admin'); - if (gr.next()) { - gs.info('we got one'); - gs.info(gr.location.getAttribute('tree_picker')); - } -} -(function() { - var gr = new GlideRecord('incident'); - gr.get('sys_id', 'ef43c6d40a0a0b5700c77f9bf387afe3'); - gs.info(gr.getDisplayValue()); -})(); -(function() { - var gr = new GlideRecord('incident'); - var ed = gr.getED(); - gs.info(ed.getLabel()); -})(); -(function() { - var elementName = 'short_description'; - var gr = new GlideRecord('incident'); - gr.initialize(); - gr.setValue(elementName, 'My DB is not working'); - gr.insert(); - gs.info(gr.getElement('short_description')); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.addQuery('active', true); - gr.addQuery('priority', 1); - gr.query(); - var encodedQuery = gr.getEncodedQuery(); - gs.info(encodedQuery); -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gr.getLabel()); -})(); -(function() { - // Setup a data policy where short_description field in incident is mandatory - var gr = new GlideRecord('incident'); - gr.insert(); // insert without data in mandatory field - var errormessage = gr.getLastErrorMessage(); - gs.info(errormessage); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.addActiveQuery(); - gr.addQuery('priority', 1); - gr.query(); - gr.next(); - gs.info(gs.getProperty('glide.servlet.uri') + gr.getLink(false)); -})(); -(function() { - var gr = new GlideRecord('incident'); - var recordClassName = gr.getRecordClassName(); - gs.info(recordClassName); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.query(); - gs.info('Records in incident table: ' + gr.getRowCount()); -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gr.getTableName()); -})(); -(function() { - var gr = new GlideRecord('kb_knowledge'); - gr.query(); - gr.next(); - var uniqueid = gr.getUniqueValue(); - gs.info(uniqueid); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.orderBy('number'); - gr.query('active', 'true'); - gr.next(); - gs.info(gr.getValue('number')); -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.query(); - if (rec.hasNext()) { - gs.info('Table is not empty'); - } -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.initialize(); - gr.name = 'New Incident'; - gr.description = 'Incident description'; - gr.insert(); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.initialize(); - gr.name = 'New Incident'; - gr.description = 'Incident description'; - gr.insert(); -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gr.isActionAborted()); -})(); -(function() { - var gr = new GlideRecord('x_app_table'); - gr.newRecord(); // create a new record and populate it with default values - gs.info(gr.isNewRecord()); -})(); -(function() { - var gr = new GlideRecord('incident'); - gs.info(gr.isValid()); - var anotherGr = new GlideRecord('wrong_table_name'); - gs.info(anotherGr.isValid()); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.initialize(); - gs.info(gr.isValidField('short_description')); -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.query(); - while (rec.next()) { - gs.info(rec.number + ' exists'); - } - gs.info(rec.isValidRecord()); -})(); -(function() { - var gr = new GlideRecord('x_app_table'); - gr.newRecord(); - gs.info(gr.isNewRecord()); -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.query(); - while (rec.next()) { - gs.info(rec.number + ' exists'); - } -})(); -(function() { - //Commonly used in a business rule, returns insert if the current operation is insert - gs.info('current operation ' + current.operation()); -})(); -(function() { - var queryString = 'priority=2'; - var gr = new GlideRecord('incident'); - gr.orderBy('short_description'); // Ascending Order - gr.addEncodedQuery(queryString); - gr.query(); - while (gr.next()) { - gs.info(gr.short_description); - } -})(); -(function() { - var queryString = 'priority=2'; - var gr = new GlideRecord('incident'); - gr.orderByDesc('short_description'); //Descending Order - gr.addEncodedQuery(queryString); - gr.query(); - while (gr.next()) { - gs.info(gr.short_description); - } -})(); -(function() { - var rec = new GlideRecord('incident'); - rec.query(); - while (rec.next()) { - gs.info(rec.number + ' exists'); - } -})(); -(function() { - // Often used in business rule to check whether the current operation should be aborted. - if (current.size > 16) { - current.setAbortAction(true); - } -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.orderByDesc('sys_created_on'); - gr.setLimit(10); - gr.query(); // this retrieves latest 10 incident records created -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.short_description = 'The third floor printer is broken'; - gr.setNewGuidValue('eb4636ca6f6d31005be8883e6b3ee333'); - gr.insert(); - gs.info(gr.sys_id); -})(); -(function() { - var elementName = 'short_description'; - var gr = new GlideRecord('incident'); - gr.initialize(); - gr.setValue(elementName, 'My DB is not working'); - gr.insert(); -})(); -(function() { - //Enable business rules, scripts engines for x_app_table - var gr = new GlideRecord('x_app_table'); - gr.setWorkflow(true); -})(); -(function() { - var gr = new GlideRecord('incident'); - gr.get('99ebb4156fa831005be8883e6b3ee4b9'); - gr.short_description = 'Update the short description'; - gr.update(); - gs.info(gr.getElement('short_description')); -})(); -(function() { - // update the state of all active incidents to 4 - "Awaiting User Info" - var gr = new GlideRecord('incident'); - gr.addQuery('active', true); - gr.query(); - gr.setValue('state', 4); - gr.updateMultiple(); -})(); -(function() { - var rec = new GlideRecord('sys_template'); - rec.query(); - while (rec._next()) { - gs.info(rec.number + ' exists'); - } -})(); -(function() { - var rec = new GlideRecord('sys_app_module'); - rec._query(); - while (rec.next()) { - gs.info(rec.number + ' exists'); - } -})(); diff --git a/types/servicenow-london/test/ScopedQueryCondition.ts b/types/servicenow-london/test/ScopedQueryCondition.ts deleted file mode 100644 index 3a818b966a..0000000000 --- a/types/servicenow-london/test/ScopedQueryCondition.ts +++ /dev/null @@ -1,26 +0,0 @@ -(function() { - var gr = new GlideRecord('incident'); - var qc = gr.addQuery('category', 'Hardware'); - qc.addCondition('category', 'Network'); - gr.addQuery('number', 'INC0000003'); - gr.next(); - gr.number; - gs.info(gr.getEncodedQuery()); -})(); -(function() { - var gr = new GlideRecord('incident'); - var qc = gr.addQuery('category', 'Hardware'); - qc.addOrCondition('category', 'Network'); - gr.addQuery('number', 'INC0000003'); - gr.next(); - gr.number; - gs.info(gr.getEncodedQuery()); -})(); -(function() { - var myObj = new GlideRecord('incident'); - var q1 = myObj.addQuery('state', '<', 3); - q1.addOrCondition('state', '>', 5); - var q2 = myObj.addQuery('priority', 1); - q2.addOrCondition('priority', 5); - myObj.query(); -})(); diff --git a/types/servicenow-london/test/Workflow.ts b/types/servicenow-london/test/Workflow.ts deleted file mode 100644 index bbe5710899..0000000000 --- a/types/servicenow-london/test/Workflow.ts +++ /dev/null @@ -1,134 +0,0 @@ -(function() { - var gr = new GlideRecord('change_request'); - gr.get('8ecd7552db252200a6a2b31be0b8f581'); - - var wf = new global.Workflow(); - var grFlows = wf.getRunningFlows(gr); - while (grFlows.next()) { - wf.broadcastEvent(grFlows.sys_id, 'resume'); - } -})(); -(function() { - var gr = new GlideRecord('change_request'); - gr.get('8ecd7552db252200a6a2b31be0b8f581'); - - var wf = new global.Workflow(); - wf.cancel(gr); -})(); -(function() { - // If a workflow has started for this item, cancel it, where current is a task record with a workflow context - if (current.stage == 'Request Cancelled' && current.context && !current.context.nil()) { - var w = new global.Workflow(); - var gr = new GlideRecord('wf_context'); - - if (gr.get(current.context)) w.cancelContext(gr); - } -})(); -(function() { - var wkfw = new global.Workflow(); - wkfw.deleteWorkflow(current); -})(); -(function() { - // where current is a task record with a workflow context - var w = new global.Workflow(); - w.fireEvent(current, 'execute'); -})(); -(function() { - var wkfw = new global.Workflow(); - wkfw.fireEventById('f2400ec10b0a3c1c00ca5bb5c6fae427', 'Timer'); -})(); -(function() { - //where current is a task record with a workflow context - var wkfw = new global.Workflow(); - gs.info(wkfw.getContexts(current).started); -})(); -(function() { - var wkfw = new global.Workflow(); - gs.info(wkfw.getEstimatedDeliveryTime('b99a866a4a3623120074c033e005418f')); -})(); -(function() { - //where current is a task record with a workflow context - var wkfw = new global.Workflow(); - var context = wkfw.getContexts(current); - gs.info(wkfw.getEstimatedDeliveryTimeFromWFVersion(context.wf_version)); -})(); -(function() { - var gr = new GlideRecord('wf_context'); - gr.get('08a90c3adba52200a6a2b31be0b8f565'); - var wkfw = new global.Workflow(); - wkfw.getReturnValue(gr); -})(); -(function() { - //where current is a task record with a workflow context - var wf = new global.Workflow().getRunningFlows(current); - while (wf.next()) { - new global.Workflow().broadcastEvent(wf.sys_id, 'pause'); - } -})(); -(function() { - var wkfw = new global.Workflow(); - var gr = wkfw.getVersion('b99a866a4a3623120074c033e005418f'); -})(); -(function() { - var wkfw = new global.Workflow(); - var ge = wkfw.getVersionFromName('Emergency Change'); -})(); -(function() { - var wkfw = new global.Workflow(); - var s = wkfw.getWorkflowFromName('Emergency Change'); -})(); -(function() { - var gr = new GlideRecord('change_request'); - gr.get('cecdb552db252200a6a2b31be0b8f50b'); - var wkfw = new global.Workflow(); - gs.info(wkfw.hasWorkflow(gr)); -})(); -(function() { - var gr = new GlideRecord('change_request'); - gr.get('cecdb552db252200a6a2b31be0b8f50b'); - new global.Workflow().restartWorkflow(gr); -})(); -(function() { - var gr = new GlideRecord('change_request'); - gr.get('cecdb552db252200a6a2b31be0b8f50b'); - var wkfw = new global.Workflow(); - wkfw.runFlows(gr, 'update'); -})(); -(function() { - ////where current is a task record with a workflow context - var w = new global.Workflow(); - var context = w.startFlow('sys_id', current, current.operation(), {}); -})(); -(function() { - //where current is a task record with a workflow context - current.name = current.workflow_version.name; - current.started_by.setValue(gs.getUserID()); - - if (gs.nil(current.id)) { - var gr = new GlideRecord('wf_workflow_execution'); - gr.name = current.name; - gr.insert(); - - current.table = 'wf_workflow_execution'; - current.id = gr.sys_id; - } - - var wf = new global.Workflow(); - wf.startFlowFromContextInsert(current, current.operation()); -})(); -(function() { - var id = 'sys_id'; - // is this a retroactive start? - ////where current is a task record with a workflow context - var msecs = - new GlideDateTime().getNumericValue() - - current.start_time.getGlideObject().getNumericValue(); - - // treat this as a retroactive workflow start if the SLA started more than 5 seconds ago - var w = new global.Workflow(); - if (msecs <= 5000) w.startFlow(id, current, current.operation()); - else w.startFlowRetroactive(id, msecs, current, current.operation()); - - // update the record in case the workflow changed some values - current.update(); -})(); diff --git a/types/servicenow-london/test/XMLDocument2.ts b/types/servicenow-london/test/XMLDocument2.ts deleted file mode 100644 index 5ef77cc906..0000000000 --- a/types/servicenow-london/test/XMLDocument2.ts +++ /dev/null @@ -1,153 +0,0 @@ -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - xmlDoc.createElement('new2'); - - gs.info(xmlDoc); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - xmlDoc.createElementWithTextValue('new', 'test'); - gs.info(xmlDoc); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - //returns the root node of the document tree. - var rootNode = xmlDoc.getDocumentElement(); - gs.info(rootNode.getTextContent()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var foo = xmlDoc.getFirstNode('/test/one/two'); - gs.info(foo.getTextContent()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var foo = xmlDoc.getFirstNode('/test/one/two'); - var foo2 = xmlDoc.getNextNode(foo); - gs.info(foo.getTextContent()); - gs.info(foo2.getTextContent()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('/test/one/two'); - gs.info(node); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - gs.info(xmlDoc.getNodeText('//two')); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var rootNode = xmlDoc.getDocumentElement(); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - //returns the root node of the document tree. - var rootNode = xmlDoc.getDocumentElement(); //returns org.w3c.dom.Element - // sets the root node as the current element - xmlDoc.setCurrentElement(rootNode); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - gs.info(xmlDoc.toString()); -})(); diff --git a/types/servicenow-london/test/XMLNode.ts b/types/servicenow-london/test/XMLNode.ts deleted file mode 100644 index a5db5cd6ed..0000000000 --- a/types/servicenow-london/test/XMLNode.ts +++ /dev/null @@ -1,137 +0,0 @@ -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//two'); - gs.info(node.getAttribute('att')); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - var iter = node.getChildNodeIterator(); - gs.info(iter.hasNext()); -})(); -(function() { - var xmlString = - '' + - '' + - 'abcd1234' + - '1234abcd' + - 'another' + - '' + - '1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - gs.info(node.getFirstChild()); -})(); -(function() { - var xmlString = - '' + - '' + - 'abcd1234' + - '1234abcd' + - 'another' + - '' + - '1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - - gs.info(node.getLastChild()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//two'); - gs.info(node.getNodeName()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//two'); - gs.info(node.getNodeValue()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmldoc = new XMLDocument2(); - xmldoc.parseXML(xmlString); - var node = xmldoc.getNode('//one/two'); - gs.info(node.getTextContent()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//two'); - gs.info(node.hasAttribute('att')); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - gs.info(node.toString()); -})(); diff --git a/types/servicenow-london/test/XMLNodeIterator.ts b/types/servicenow-london/test/XMLNodeIterator.ts deleted file mode 100644 index 50e58e8f83..0000000000 --- a/types/servicenow-london/test/XMLNodeIterator.ts +++ /dev/null @@ -1,36 +0,0 @@ -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - var iter = node.getChildNodeIterator(); - gs.info(iter.hasNext()); -})(); -(function() { - var xmlString = - '' + - ' ' + - ' abcd1234' + - ' 1234abcd' + - ' another' + - ' ' + - ' 1234' + - ''; - var xmlDoc = new XMLDocument2(); - xmlDoc.parseXML(xmlString); - var node = xmlDoc.getNode('//one'); - var iter = node.getChildNodeIterator(); - while (iter.hasNext()) { - var n = iter.next(); - gs.info('Node name: ' + n.getNodeName()); - gs.info('Node value: ' + n.getNodeValue()); - } -})(); diff --git a/types/servicenow-london/tsconfig.json b/types/servicenow-london/tsconfig.json index 53dd1d713d..3302148bc7 100644 --- a/types/servicenow-london/tsconfig.json +++ b/types/servicenow-london/tsconfig.json @@ -56,42 +56,6 @@ "XMLNode.d.ts", "XMLNodeIterator.d.ts", - "test/Class.ts", - "test/GlideDate.ts", - "test/GlideDateTime.ts", - "test/GlideDBFunctionBuilder.ts", - "test/GlideDuration.ts", - "test/GlideEmailOutbound.ts", - "test/GlideFilter.ts", - "test/GlideLocale.ts", - "test/GlidePluginManager.ts", - "test/GlideSchedule.ts", - "test/GlideScopedEvaluator.ts", - "test/GlideScriptedProcessor.ts", - "test/GlideSecureRandomUtil.ts", - "test/GlideServletRequest.ts", - "test/GlideServletResponse.ts", - "test/GlideSession.ts", - "test/GlideStringUtil.ts", - "test/GlideSysAttachment.ts", - "test/GlideSystem.ts", - "test/GlideTime.ts", - "test/GlideUser.ts", - "test/RESTAPIRequest.ts", - "test/RESTAPIRequestBody.ts", - "test/RESTAPIResponse.ts", - "test/RESTAPIResponseStream.ts", - "test/RESTMessageV2.ts", - "test/RESTResponseV2.ts", - "test/ScopedElementDescriptor.ts", - "test/ScopedGlideElement.ts", - "test/ScopedGlideRecord.ts", - "test/ScopedQueryCondition.ts", - "test/SOAPMessageV2.ts", - "test/SOAPResponseV2.ts", - "test/Workflow.ts", - "test/XMLDocument2.ts", - "test/XMLNode.ts", - "test/XMLNodeIterator.ts" + "servicenow-london-tests.ts" ] } diff --git a/types/servicenow-london/tslint.json b/types/servicenow-london/tslint.json index 1e1f71979b..e595b70d63 100644 --- a/types/servicenow-london/tslint.json +++ b/types/servicenow-london/tslint.json @@ -1,12 +1,3 @@ { "extends": "dtslint/dt.json", - "rules": { - // Interface is needed for merging GlideRecord types - "no-misused-new": false, - // Disabling to all separate JSDoc per signature to correspond with ServiceNow API docs - "unified-signatures": false - }, - "linterOptions": { - "exclude": ["test/*.ts"] - } } From ebb1d54175602aadab6da28e93b7380bad4c2706 Mon Sep 17 00:00:00 2001 From: John Caruso Date: Mon, 25 Mar 2019 17:24:16 -0500 Subject: [PATCH 3/6] Fix tslint.json --- types/servicenow-london/tslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/servicenow-london/tslint.json b/types/servicenow-london/tslint.json index e595b70d63..f93cf8562a 100644 --- a/types/servicenow-london/tslint.json +++ b/types/servicenow-london/tslint.json @@ -1,3 +1,3 @@ { - "extends": "dtslint/dt.json", + "extends": "dtslint/dt.json" } From 5e4ad116c462700a5261bf4a2c6efe0fd10428bc Mon Sep 17 00:00:00 2001 From: John Caruso Date: Mon, 25 Mar 2019 17:33:37 -0500 Subject: [PATCH 4/6] Fix lint issues --- types/servicenow-london/GlideDateTime.d.ts | 2 ++ types/servicenow-london/GlideDuration.d.ts | 2 ++ types/servicenow-london/GlideEmailOutbound.d.ts | 2 ++ types/servicenow-london/GlideSchedule.d.ts | 2 ++ types/servicenow-london/GlideTime.d.ts | 2 ++ types/servicenow-london/RESTMessageV2.d.ts | 2 ++ types/servicenow-london/ScopedGlideRecord.d.ts | 2 ++ 7 files changed, 14 insertions(+) diff --git a/types/servicenow-london/GlideDateTime.d.ts b/types/servicenow-london/GlideDateTime.d.ts index ad4ef1210b..abaacc1049 100644 --- a/types/servicenow-london/GlideDateTime.d.ts +++ b/types/servicenow-london/GlideDateTime.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + /** * The scoped GlideDateTime class provides methods for performing operations on GlideDateTime * objects, such as instantiating GlideDateTime objects or working with glide_date_time fields. diff --git a/types/servicenow-london/GlideDuration.d.ts b/types/servicenow-london/GlideDuration.d.ts index b616be5000..fe8fdb94f9 100644 --- a/types/servicenow-london/GlideDuration.d.ts +++ b/types/servicenow-london/GlideDuration.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + /** * The scoped GlideDuration class provides methods for working with spans of time or durations. * diff --git a/types/servicenow-london/GlideEmailOutbound.d.ts b/types/servicenow-london/GlideEmailOutbound.d.ts index c9589efb71..5e0c19e817 100644 --- a/types/servicenow-london/GlideEmailOutbound.d.ts +++ b/types/servicenow-london/GlideEmailOutbound.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + /** * The scoped GlideEmailOutbound class implements the email object for scoped applications. * You can use the GlideEmailOutbound methods with the email global object available in mail diff --git a/types/servicenow-london/GlideSchedule.d.ts b/types/servicenow-london/GlideSchedule.d.ts index 435b7c8506..f530954ddb 100644 --- a/types/servicenow-london/GlideSchedule.d.ts +++ b/types/servicenow-london/GlideSchedule.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + /** * 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 diff --git a/types/servicenow-london/GlideTime.d.ts b/types/servicenow-london/GlideTime.d.ts index d51854e7a6..e34760970f 100644 --- a/types/servicenow-london/GlideTime.d.ts +++ b/types/servicenow-london/GlideTime.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + /** * The scoped GlideTime class provides methods for performing operations on GlideTime * objects, such as instantiating GlideTime objects or working with GlideTime fields. diff --git a/types/servicenow-london/RESTMessageV2.d.ts b/types/servicenow-london/RESTMessageV2.d.ts index fadac635aa..02401a531c 100644 --- a/types/servicenow-london/RESTMessageV2.d.ts +++ b/types/servicenow-london/RESTMessageV2.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures */ + declare namespace sn_ws { /** * The RESTMessageV2 API allows you to send outbound REST messages using JavaScript. diff --git a/types/servicenow-london/ScopedGlideRecord.d.ts b/types/servicenow-london/ScopedGlideRecord.d.ts index 3e3dfb7bc5..9c6583acda 100644 --- a/types/servicenow-london/ScopedGlideRecord.d.ts +++ b/types/servicenow-london/ScopedGlideRecord.d.ts @@ -1,3 +1,5 @@ +/* tslint:disable:unified-signatures no-misused-new */ + /** * Scoped GlideRecord is used for database operations. */ From d094dd8557e499c4b94bcfda6d5189298fbf1c52 Mon Sep 17 00:00:00 2001 From: John Caruso Date: Thu, 28 Mar 2019 17:57:12 -0500 Subject: [PATCH 5/6] Added more JSDocs --- types/servicenow-london/GlideFilter.d.ts | 34 ++++++++++ types/servicenow-london/GlideLocale.d.ts | 39 +++++++++++- .../servicenow-london/GlidePluginManager.d.ts | 29 +++++++++ .../GlideScriptedProcessor.d.ts | 62 ++++++++++++++++++- .../GlideSecureRandomUtil.d.ts | 46 ++++++++++++++ 5 files changed, 208 insertions(+), 2 deletions(-) diff --git a/types/servicenow-london/GlideFilter.d.ts b/types/servicenow-london/GlideFilter.d.ts index 31694e19b7..9edf32d262 100644 --- a/types/servicenow-london/GlideFilter.d.ts +++ b/types/servicenow-london/GlideFilter.d.ts @@ -1,3 +1,37 @@ +/** + * The Scoped GlideFilter API provides a method to determine if a record meets a specified set of + * requirements. + * + * There is no constructor for Scoped GlideFilter. It is accessed by using the global object + * `GlideFilter`. + */ declare const GlideFilter: { + /** + * The filter parameter is an encoded query string. + * + * The method returns true when the record meets the filter condition. If the filter is composed + * of one or more "AND" conditions for example `active=true^number=abc^category=request` and the + * matchAll parameter is set to false, then if any of the conditions is true then true is + * returned. If the matchAll parameter is true, then all conditions in the filter must be true + * in order to return true. + * + * @param gr The GlideRecord to be evaluated. + * @param filter An encoded query string. + * @param matchAll (Optional) If true and the encoded query string contains multiple conditions + * then all conditions must be true for the method to return true. If false and the encoded + * query string contains multiple conditions then only one condition needs to be true for the + * method to return true. If the encoded query string has only one condition, this parameter has + * no impact. + * @returns True when the record meets the filter conditions. + * @example + * + * var rec = new GlideRecord('incident'); + * rec.query(); + * var bool = true; + * while(rec.next()) { + * bool = GlideFilter.checkRecord(rec, 'active=true'); + * gs.info('number ' + rec. number + ' is ' + bool); + * } + */ checkRecord(gr: ScopedGlideRecord, filter: string, matchAll?: object): boolean; }; diff --git a/types/servicenow-london/GlideLocale.d.ts b/types/servicenow-london/GlideLocale.d.ts index 841d3d47a2..b979ec622e 100644 --- a/types/servicenow-london/GlideLocale.d.ts +++ b/types/servicenow-london/GlideLocale.d.ts @@ -1,5 +1,42 @@ +/** + * GlideLocale provides information about display information for the local instance. + * + * There is no constructor for a GlideLocale object. Use the `get()` method to get a GlideLocale + * object. + */ declare class GlideLocale { + /** + * Returns the GlideLocale object. + * + * @returns The GlideLocale object. + * @example + * + * var locale = GlideLocale.get(); + */ static get(): GlideLocale; - getGroupingSeparator(): string; + + /** + * Returns the decimal separator. + * + * @returns The decimal separator. + * @example + * + * var locale = GlideLocale.get(); + * var decimalSeparator = locale.getDecimalSeparator(); + * gs.info( "The decimal separator is " + decimalSeparator); + * // The decimal separator is . + */ getDecimalSeparator(): string; + + /** + * Returns the grouping separator. + * + * @returns The grouping separator. + * @example + * + * var locale = GlideLocale.get(); + * var groupingSeparator = locale.getGroupingSeparator(); + * gs.info( "The grouping separator is " + groupingSeparator); + */ + getGroupingSeparator(): string; } diff --git a/types/servicenow-london/GlidePluginManager.d.ts b/types/servicenow-london/GlidePluginManager.d.ts index f60dfe1433..c4860037a1 100644 --- a/types/servicenow-london/GlidePluginManager.d.ts +++ b/types/servicenow-london/GlidePluginManager.d.ts @@ -1,3 +1,32 @@ +/** + * The scoped GlidePluginManager API provides a method for determining if a plugin has been + * activated. + */ declare class GlidePluginManager { + /** + * Determines if the specified plugin has been activated. + * + * @param pluginId The plugin ID + * @returns True if the plugin has been activated. + * @example + * + * var gr = new GlideRecord('sys_plugins'); + * var queryString = "active=0^ORactive=1"; + * gr.addEncodedQuery(queryString); + * gr.query(); + * pMgr = new GlidePluginManager(); + * while (gr.next()) { + * var name = gr.getValue('name'); + * var pID = gr.getValue('source'); + * isActive = pMgr.isActive(pID); + * if (isActive) + * gs.info('The plugin ' + name + " is active" ); + * } + * // The plugin Country Lookup Data is active + * // The plugin Database Replication is active + * // The plugin REST API Provider is active + * // The plugin Ten Cool Things is active + * // ... + */ isActive(pluginId: string): boolean; } diff --git a/types/servicenow-london/GlideScriptedProcessor.d.ts b/types/servicenow-london/GlideScriptedProcessor.d.ts index 3ad2a72c97..e05a1b7dfc 100644 --- a/types/servicenow-london/GlideScriptedProcessor.d.ts +++ b/types/servicenow-london/GlideScriptedProcessor.d.ts @@ -1,5 +1,65 @@ +/* tslint:disable:unified-signatures */ + +/** + * ServiceNow processors are equivalent to Java servlets. + * + * Processors provide a customizable URL endpoint that can execute arbitrary server-side JavaScript + * code and produce output such as TEXT, JSON, or HTML. The `GlideScriptedProcessor` APIs are used + * in processor scripts to access the the processor (servlet) capabilities. There are no + * constructors for the `GlideScriptedProcessor` APIs. The methods are called using the global + * variable `g_processor`. + * + * A useful global variable, `g_target`, is available in processor scripts. It contains the table + * name extracted from the URL. + * + * The URL to a processor has the format: + * `https:///.do?=` + * where the path endpoint and parameter endpoint are defined on the processor form. + */ interface GlideScriptedProcessor { + /** + * Redirects to the specified URL. + * + * @param url the destination URL + * @example + * + * //Do whatever processing you need and redirect to the homepage + * g_processor.redirect("/navpage.do") + */ redirect(url: string): void; - writeOutput(contentType: string, s?: string): void; + + /** + * Encodes an object as a JSON string and writes it to the current URL. + * + * @param o The object to encode to a JSON string. + * @example + * + * var map = {"key1":"value1","key2":"value2"}; + * g_processor.writeJSON(map); + */ writeJSON(o: object): void; + + /** + * Writes the specified string to the current URL in the specified character-encoding. + * + * @param contentType Sets the content type of the response sent to the client, if the response + * has not been committed, and may include a character-encoding specification. + * @param s The string to write. + * @example + * + * var name = g_request.getParameter("name"); + * g_processor.writeOutput("text/plain", "Hello " + name); + */ + writeOutput(contentType: string, s: string): void; + + /** + * Writes the specified string to the current URL. + * + * @param s The string to write. + * @example + * + * var name = g_request.getParameter("name"); + * g_processor.writeOutput("Hello " + name); + */ + writeOutput(s: string): void; } diff --git a/types/servicenow-london/GlideSecureRandomUtil.d.ts b/types/servicenow-london/GlideSecureRandomUtil.d.ts index 545354d30a..d768a29f80 100644 --- a/types/servicenow-london/GlideSecureRandomUtil.d.ts +++ b/types/servicenow-london/GlideSecureRandomUtil.d.ts @@ -1,6 +1,52 @@ +/** + * The scoped GlideSecureRandomUtil API provides methods for generating integers, long values, and + * strings. + * + * There is no constructor for this class. Methods are accessed through the static object + * `GlideSecureRandomUtil`. The `GlideSecureRandomUtil` class is available in both global and scoped + * applications. + */ declare const GlideSecureRandomUtil: { + /** + * Generates a pseudo-random integer. + * + * @returns The pseudo-randomly generated integer. + * @example + * + * gs.info(GlideSecureRandomUtil.getSecureRandomInt()); + */ getSecureRandomInt(): number; + + /** + * Generates a pseudo-random integer between 0 (inclusive) and the bound (exclusive) value that + * you pass into the method. + * + * @param bound The bound value. + * @returns The pseudo-randomly generated integer. + * @example + * + * gs.info(GlideSecureRandomUtil.getSecureRandomIntBound(100)); + */ getSecureRandomIntBound(bound: number): number; + + /** + * Generates pseudo-random long value. + * + * @returns The pseudo-randomly generated 64-bit integer. + * @example + * + * gs.info(GlideSecureRandomUtil.getSecureRandomLong()); + */ getSecureRandomLong(): number; + + /** + * Generates a random alpha-numeric String with the specified length. + * + * @param length The length of the string in number of characters. + * @returns The randomly generated string. + * @example + * + * gs.info(GlideSecureRandomUtil.getSecureRandomString(12)); + */ getSecureRandomString(length: number): string; }; From 97682b1e75d4f80583b3562b5e5fb4a64f610eb3 Mon Sep 17 00:00:00 2001 From: John Caruso Date: Thu, 28 Mar 2019 18:01:57 -0500 Subject: [PATCH 6/6] Fix lint errors --- types/servicenow-london/GlideFilter.d.ts | 24 +++++------ .../servicenow-london/GlidePluginManager.d.ts | 14 +++---- .../GlideScriptedProcessor.d.ts | 42 +++++++++---------- .../GlideSecureRandomUtil.d.ts | 6 +-- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/types/servicenow-london/GlideFilter.d.ts b/types/servicenow-london/GlideFilter.d.ts index 9edf32d262..6da49ac995 100644 --- a/types/servicenow-london/GlideFilter.d.ts +++ b/types/servicenow-london/GlideFilter.d.ts @@ -1,30 +1,30 @@ /** - * The Scoped GlideFilter API provides a method to determine if a record meets a specified set of + * The Scoped GlideFilter API provides a method to determine if a record meets a specified set of * requirements. - * - * There is no constructor for Scoped GlideFilter. It is accessed by using the global object + * + * There is no constructor for Scoped GlideFilter. It is accessed by using the global object * `GlideFilter`. */ declare const GlideFilter: { /** * The filter parameter is an encoded query string. - * + * * The method returns true when the record meets the filter condition. If the filter is composed * of one or more "AND" conditions for example `active=true^number=abc^category=request` and the - * matchAll parameter is set to false, then if any of the conditions is true then true is - * returned. If the matchAll parameter is true, then all conditions in the filter must be true + * matchAll parameter is set to false, then if any of the conditions is true then true is + * returned. If the matchAll parameter is true, then all conditions in the filter must be true * in order to return true. - * + * * @param gr The GlideRecord to be evaluated. * @param filter An encoded query string. - * @param matchAll (Optional) If true and the encoded query string contains multiple conditions - * then all conditions must be true for the method to return true. If false and the encoded - * query string contains multiple conditions then only one condition needs to be true for the + * @param matchAll (Optional) If true and the encoded query string contains multiple conditions + * then all conditions must be true for the method to return true. If false and the encoded + * query string contains multiple conditions then only one condition needs to be true for the * method to return true. If the encoded query string has only one condition, this parameter has * no impact. * @returns True when the record meets the filter conditions. - * @example - * + * @example + * * var rec = new GlideRecord('incident'); * rec.query(); * var bool = true; diff --git a/types/servicenow-london/GlidePluginManager.d.ts b/types/servicenow-london/GlidePluginManager.d.ts index c4860037a1..0dad2c2a24 100644 --- a/types/servicenow-london/GlidePluginManager.d.ts +++ b/types/servicenow-london/GlidePluginManager.d.ts @@ -5,11 +5,11 @@ declare class GlidePluginManager { /** * Determines if the specified plugin has been activated. - * + * * @param pluginId The plugin ID * @returns True if the plugin has been activated. - * @example - * + * @example + * * var gr = new GlideRecord('sys_plugins'); * var queryString = "active=0^ORactive=1"; * gr.addEncodedQuery(queryString); @@ -22,10 +22,10 @@ declare class GlidePluginManager { * if (isActive) * gs.info('The plugin ' + name + " is active" ); * } - * // The plugin Country Lookup Data is active - * // The plugin Database Replication is active - * // The plugin REST API Provider is active - * // The plugin Ten Cool Things is active + * // The plugin Country Lookup Data is active + * // The plugin Database Replication is active + * // The plugin REST API Provider is active + * // The plugin Ten Cool Things is active * // ... */ isActive(pluginId: string): boolean; diff --git a/types/servicenow-london/GlideScriptedProcessor.d.ts b/types/servicenow-london/GlideScriptedProcessor.d.ts index e05a1b7dfc..ae5476690e 100644 --- a/types/servicenow-london/GlideScriptedProcessor.d.ts +++ b/types/servicenow-london/GlideScriptedProcessor.d.ts @@ -2,27 +2,27 @@ /** * ServiceNow processors are equivalent to Java servlets. - * - * Processors provide a customizable URL endpoint that can execute arbitrary server-side JavaScript - * code and produce output such as TEXT, JSON, or HTML. The `GlideScriptedProcessor` APIs are used - * in processor scripts to access the the processor (servlet) capabilities. There are no - * constructors for the `GlideScriptedProcessor` APIs. The methods are called using the global + * + * Processors provide a customizable URL endpoint that can execute arbitrary server-side JavaScript + * code and produce output such as TEXT, JSON, or HTML. The `GlideScriptedProcessor` APIs are used + * in processor scripts to access the the processor (servlet) capabilities. There are no + * constructors for the `GlideScriptedProcessor` APIs. The methods are called using the global * variable `g_processor`. - * - * A useful global variable, `g_target`, is available in processor scripts. It contains the table + * + * A useful global variable, `g_target`, is available in processor scripts. It contains the table * name extracted from the URL. - * - * The URL to a processor has the format: - * `https:///.do?=` + * + * The URL to a processor has the format: + * `https:///.do?=` * where the path endpoint and parameter endpoint are defined on the processor form. */ interface GlideScriptedProcessor { /** * Redirects to the specified URL. - * + * * @param url the destination URL - * @example - * + * @example + * * //Do whatever processing you need and redirect to the homepage * g_processor.redirect("/navpage.do") */ @@ -30,10 +30,10 @@ interface GlideScriptedProcessor { /** * Encodes an object as a JSON string and writes it to the current URL. - * + * * @param o The object to encode to a JSON string. - * @example - * + * @example + * * var map = {"key1":"value1","key2":"value2"}; * g_processor.writeJSON(map); */ @@ -41,12 +41,12 @@ interface GlideScriptedProcessor { /** * Writes the specified string to the current URL in the specified character-encoding. - * - * @param contentType Sets the content type of the response sent to the client, if the response + * + * @param contentType Sets the content type of the response sent to the client, if the response * has not been committed, and may include a character-encoding specification. * @param s The string to write. - * @example - * + * @example + * * var name = g_request.getParameter("name"); * g_processor.writeOutput("text/plain", "Hello " + name); */ @@ -54,7 +54,7 @@ interface GlideScriptedProcessor { /** * Writes the specified string to the current URL. - * + * * @param s The string to write. * @example * diff --git a/types/servicenow-london/GlideSecureRandomUtil.d.ts b/types/servicenow-london/GlideSecureRandomUtil.d.ts index d768a29f80..1379192936 100644 --- a/types/servicenow-london/GlideSecureRandomUtil.d.ts +++ b/types/servicenow-london/GlideSecureRandomUtil.d.ts @@ -1,8 +1,8 @@ /** - * The scoped GlideSecureRandomUtil API provides methods for generating integers, long values, and + * The scoped GlideSecureRandomUtil API provides methods for generating integers, long values, and * strings. - * - * There is no constructor for this class. Methods are accessed through the static object + * + * There is no constructor for this class. Methods are accessed through the static object * `GlideSecureRandomUtil`. The `GlideSecureRandomUtil` class is available in both global and scoped * applications. */