Hsl JavaScript Library
The Hsl JavaScript Library provides a variety of functionality helping make web service calls and manage forms.
The main file to reference when using the library is hsl_/jslib/v9/library.core.js. If you're updating from version 8 see the upgrade documentation.
Functionality
The documentation is split into different areas on functionality.
- General General functionality
- PromiseHelper Helpers for processing arrays of data using promises.
- CurrentUser Provides information about the user's roles and privileges.
- Lookup Displays a modal lookup dialog.
- WebApi Functionality for making web service calls to the Web API endpoint.
- Dialog Functionality for showing modal dialogs.
- Form Functionality for model driven entity forms.
- OrgService Functionality for using the deprecated SOAP endpoint.
- v8 to v9 upgrade Information on updating from the older version of the library.
- Change Log
Method Definition Syntax
Method definitions throughout this document use type annotations following the conventions from TypeScript The TypeScript syntax is used only for annotation of the types expected by the methods in the library.
** Despite the library using TypeScript, writing plain JavaScript with the library works just fine. **
- Parameters use a
:
followed by a type name to indicate the type.?:
indicates an optional parameter. |
is a union type indicates either type is valid.string | number
would indicate that the parameter can be either a string or number.- Square brackets are used to indicate an array.
number[]
would define a number array like[1, 20, 300]
- Generics work using angle bracks. For example
Hsl.firstItemInArray<T>(array: T[]): T
means the method takes an array of any type and returns an element of that type. Dictionary<TYPE>
refers to an option whose values are the given type. For example, Dictionary<number> would be an object whose values are numbers like{ x: 5, y: 6, z: 0 }
Promise<TYPE>
refers to a Promise that will resolve to a value of the given type.- Arrow syntax is used to defined functions.
(key: string) => number
would be a function that takes a string and returns a number.
So in this sample Hsl.sampleMethod(webResourceName: string, dataParameter?: string | Dictionary<string>)
- webResourceName is a string
- dataParameter is optional and be either a string or Dictionary<string>
Some samples will refer to interfaces these are just definitions of ojects with give keys/values. For example:
Hsl.divide(settings: DivideInput): number;
interface DivideInput {
numerator: number;
denominator: number;
}
Would refer to a function Hsl.divide
that types an object with numerator
and denominator
values that are numbers and returns a number. You'd call it like this.
var result = Hsl.divide({
numerator: 56,
denominator: 4,
});
console.log(result);// Would output 14 if Hsl.divide existed.