mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merge pull request #34162 from u-now/servicenow-london
Add new ServiceNow London API type definitions
This commit is contained in:
Vendored
+8
@@ -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;
|
||||
};
|
||||
+189
@@ -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;
|
||||
}
|
||||
+154
@@ -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;
|
||||
}
|
||||
+835
@@ -0,0 +1,835 @@
|
||||
/* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/* tslint:disable:unified-signatures */
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/* 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
|
||||
* 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;
|
||||
}
|
||||
+37
@@ -0,0 +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;
|
||||
};
|
||||
+42
@@ -0,0 +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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
+32
@@ -0,0 +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;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
type GlideRecordOperation = 'insert' | 'update' | 'delete';
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
/* 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
|
||||
* 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +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://<instance name.servicenow.com>/<path endpoint>.do?<parameter endpoint>=<value>`
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@@ -0,0 +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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
interface GlideServletResponse {
|
||||
setContentType(type: string): void;
|
||||
setHeader(name: string, value: string): void;
|
||||
setStatus(value: number): void;
|
||||
}
|
||||
+13
@@ -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;
|
||||
}
|
||||
+16
@@ -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;
|
||||
};
|
||||
+26
@@ -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;
|
||||
}
|
||||
+90
@@ -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;
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
+16
@@ -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;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
type QueryOperator =
|
||||
| '='
|
||||
| '!='
|
||||
| '>'
|
||||
| '>='
|
||||
| '<'
|
||||
| '<='
|
||||
| 'IN'
|
||||
| 'NOT IN'
|
||||
| 'STARTSWITH'
|
||||
| 'ENDSWITH'
|
||||
| 'CONTAINS'
|
||||
| 'DOES NOT CONTAIN'
|
||||
| 'INSTANCEOF'
|
||||
| 'SAMEAS';
|
||||
+13
@@ -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[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
declare namespace sn_ws {
|
||||
interface RESTAPIRequestBody {
|
||||
readonly data: any;
|
||||
readonly dataStream: object;
|
||||
readonly dataString: string;
|
||||
hasNext(): boolean;
|
||||
nextEntry(): any;
|
||||
}
|
||||
}
|
||||
+12
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
declare namespace sn_ws {
|
||||
interface RESTAPIResponseStream {
|
||||
writeStream(stream: object): void;
|
||||
writeString(data: string): void;
|
||||
}
|
||||
}
|
||||
+583
@@ -0,0 +1,583 @@
|
||||
/* tslint:disable:unified-signatures */
|
||||
|
||||
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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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 = '<attachment_record_sys_id>',
|
||||
* tablename = 'incident',
|
||||
* recordSysId = '<incident_sys_id>',
|
||||
* response,
|
||||
* httpResponseStatus,
|
||||
* filename = '<filename>';
|
||||
*
|
||||
* // endpoint - ServiceNow REST Attachment API
|
||||
* request.setEndpoint('https://<instance_name>.service-now.com/api/now/attachment/' +
|
||||
* attachment_sys_id + '/file');
|
||||
* request.setBasicAuth('<username>', '<password>');
|
||||
*
|
||||
* // 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("<REST_message_record>", "get");
|
||||
*
|
||||
* // set auth profile to an OAuth 2.0 profile record.
|
||||
* sm.setAuthenticationProfile('oauth2', '1234adsf123212131123qasdsf');
|
||||
*
|
||||
* sm.setStringParameter("symbol", "NOW");
|
||||
* sm.setStringParameterNoEscape("xml_data", "<data>test</data>");
|
||||
*
|
||||
* // 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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","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 = "<Message body content>";
|
||||
* 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('<web service endpoint URL>');
|
||||
* request.setRequestBodyFromAttachment('<attachment sys_id>');
|
||||
*
|
||||
* 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("<REST_message_record>","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("<REST_message_record>","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("<REST_message_record>","get");
|
||||
* sm.setStringParameterNoEscape("s","NOW");
|
||||
*/
|
||||
setStringParameterNoEscape(name: string, value: string): void;
|
||||
}
|
||||
|
||||
type RestHTTPMethods =
|
||||
| 'get'
|
||||
| 'post'
|
||||
| 'delete'
|
||||
| 'patch'
|
||||
| 'put'
|
||||
| 'head'
|
||||
| 'delete'
|
||||
| 'options';
|
||||
}
|
||||
+188
@@ -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('<A REST message>', '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;
|
||||
}
|
||||
}
|
||||
+13
@@ -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;
|
||||
}
|
||||
+31
@@ -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;
|
||||
}
|
||||
}
|
||||
+14
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+447
@@ -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;
|
||||
}
|
||||
+900
@@ -0,0 +1,900 @@
|
||||
/* tslint:disable:unified-signatures no-misused-new */
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
+97
@@ -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;
|
||||
}
|
||||
}
|
||||
+13
@@ -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;
|
||||
}
|
||||
Vendored
+11
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
interface XMLNodeIterator {
|
||||
hasNext(): boolean;
|
||||
next(): XMLNode;
|
||||
}
|
||||
Vendored
+62
@@ -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 <https://github.com/johncaruso>
|
||||
// Bryce Godfrey <https://github.com/bryceg>
|
||||
// Garrett Griffin <https://github.com/grgisme>
|
||||
// Erik Myrold <https://github.com/emyrold>
|
||||
// Tim Woodruff <https://github.com/thisnameissoclever>
|
||||
// Anim Yeboah <https://github.com/ayeboah>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference path="Class.d.ts" />
|
||||
/// <reference path="GlideDate.d.ts" />
|
||||
/// <reference path="GlideDateTime.d.ts" />
|
||||
/// <reference path="GlideDBFunctionBuilder.d.ts" />
|
||||
/// <reference path="GlideDuration.d.ts" />
|
||||
/// <reference path="GlideEmailOutbound.d.ts" />
|
||||
/// <reference path="GlideFilter.d.ts" />
|
||||
/// <reference path="GlideLocale.d.ts" />
|
||||
/// <reference path="GlidePluginManager.d.ts" />
|
||||
/// <reference path="GlideRecordOperation.d.ts" />
|
||||
/// <reference path="GlideSchedule.d.ts" />
|
||||
/// <reference path="GlideScopedEvaluator.d.ts" />
|
||||
/// <reference path="GlideScriptedProcessor.d.ts" />
|
||||
/// <reference path="GlideSecureRandomUtil.d.ts" />
|
||||
/// <reference path="GlideServletRequest.d.ts" />
|
||||
/// <reference path="GlideServletResponse.d.ts" />
|
||||
/// <reference path="GlideSession.d.ts" />
|
||||
/// <reference path="GlideStringUtil.d.ts" />
|
||||
/// <reference path="GlideSysAttachment.d.ts" />
|
||||
/// <reference path="GlideSystem.d.ts" />
|
||||
/// <reference path="GlideTime.d.ts" />
|
||||
/// <reference path="GlideUser.d.ts" />
|
||||
/// <reference path="QueryOperator.d.ts" />
|
||||
/// <reference path="RenderProperties.d.ts" />
|
||||
/// <reference path="RESTAPIRequest.d.ts" />
|
||||
/// <reference path="RESTAPIRequestBody.d.ts" />
|
||||
/// <reference path="RESTAPIResponse.d.ts" />
|
||||
/// <reference path="RESTAPIResponseStream.d.ts" />
|
||||
/// <reference path="RESTMessageV2.d.ts" />
|
||||
/// <reference path="RESTResponseV2.d.ts" />
|
||||
/// <reference path="ScopedElementDescriptor.d.ts" />
|
||||
/// <reference path="ScopedGlideElement.d.ts" />
|
||||
/// <reference path="ScopedGlideRecord.d.ts" />
|
||||
/// <reference path="ScopedQueryCondition.d.ts" />
|
||||
/// <reference path="SOAPMessageV2.d.ts" />
|
||||
/// <reference path="SOAPResponseV2.d.ts" />
|
||||
/// <reference path="Workflow.d.ts" />
|
||||
/// <reference path="XMLDocument2.d.ts" />
|
||||
/// <reference path="XMLNode.d.ts" />
|
||||
/// <reference path="XMLNodeIterator.d.ts" />
|
||||
|
||||
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;
|
||||
@@ -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';
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"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",
|
||||
|
||||
"servicenow-london-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user