Skip to content

Application

Application

Abstract

Summary of the Application class

Class Description

The class represents an eLegere Application. The class offers methods to create, delete, and read rows both on master and detail tables. In order to create an application object, use either the getApplication or getApplicationFromToken functions, or the environment.getApplication or domain.getApplication methods.

Note

The class requires the initialization through the elegere object.

Methods

deleteMany Promise<SaveResult>

1
deleteMany(items: object[]): Promise<SaveResult>

deleteMany() deletes multiple rows from an eLegere master table.

For Example:

1
application.deleteMany([{Id: firstRow.Id, TIMESTAMP: firstRow.TIMESTAMP}, {Id: secondRow.Id, TIMESTAMP: secondRow.TIMESTAMP}])
Parameters

items

object[] Each object represents an eLegere Master row. Every object must contain a row Id and a TIMESTAMP field.

Return

A promise that returns SaveResult object.

deleteManyDetail Promise<SaveResult>

1
deleteManyDetail(detailName: string, details: object[]): Promise<SaveResult>

deleteManyDetail() deletes several rows from the Details of an Application. Each separate row of the detail constitutes an object.

1
application.deleteManyDetail("Documents", [{Id: firstDetail.Id, TIMESTAMP: firstDetail.TIMESTAMP}, {Id: secondDetail.Id, TIMESTAMP: secondDetail.TIMESTAMP}])
Parameters

detailName

string detailName defines the specific Detail Tab containing the rows.

details

object[] Each object represents an eLegere Detail row. Every object must contain Id and TIMESTAMP fields.

Return

A promise that returns SaveResult object.

deleteOne Promise<SaveResult>

1
deleteOne(item: object): Promise<SaveResult>

deleteOne() deletes a single row from the eLegere Master table.

For Example:

1
application.deleteOne({Id: row.Id, TIMESTAMP: row.TIMESTAMP}})
Parameters

item

object The parameter defines the specific row Id and Timestamp.

Return

A promise that returns SaveResult object.

deleteOneDetail Promise<SaveResult>

1
deleteOneDetail(detailName: string, detail: object): Promise<SaveResult>

deleteOneDetail() deletes a particular row of a Detail table in an Application.

For Example:

1
application.deleteOneDetail("Documents", [{Id: detail.Id, TIMESTAMP: detail.TIMESTAMP}])
Parameters

detailName

string Defines the specific Detail Tab containing the rows.

detail

object Defines a JavaScript object identifying a single detail row. It must contain a row Id and a TIMESTAMP field.

Return

A promise that returns SaveResult object.

getDetails Promise<ReadResult>

1
getDetails(detailName: string, filter?: string, top?: number): Promise<ReadResult>

getDetails() recovers a list containing one or more items from an Application's Detail table.

For Example:

1
2
3
4
5
6
7
8
 // This example fetches the first 30 rows from the detail "Project Team" that are currently working on the "Saudi Arabian Oil Co." project (which corresponds to an Id_Project of 3) whose role is "Application Designer" (which corresponds to an Id_Role of 1) and whose hourly cost is lower than 300, 

const detailTableName = "Project Team";
const filter = Id_Project eq 3 and Id_Role eq 1 and Cost lt 300
const top = 30
const getDetailsResult = await projectsApp.getDetails(detailTableName, filter, top)

// getItemsResult contains informations on the query. Its Items field contains a list of rows
Parameters

detailName

string detailName defines the specific Detail Tab containing the rows.

filter

string The parameter is a OData filter for detailName: it points the items to retrive from the Detail table. The parameter is optional.

filter: string supports the following OData filters:

  • eq
  • ne
  • gt
  • ge
  • lt
  • le
  • and
  • or
  • substringof
  • dr (custom eLegere OData filter)
  • multi (custom eLegere OData filter)

top

number Points how many items to fetch from the Detail table. The parameter is optional. If left empty, the default value will be 20.

Return

A Promise that returns a ReadResult object.

getItems Promise<ReadResult>

1
getItems(filter?: string, top?: number): Promise<ReadResult>

getItems() fetches one or more items from the Master table of the Application.

For Example:

1
2
3
4
5
// This example fetches the top 100 rows from the Projects app that are already completed

const filter = Completed eq true
const top = 100
const getItemsResult = await projectsApp.getItems(filter, top)
Parameters

filter

string The parameter is a OData filter for detailName: it points the items to retrive from the Master table. The parameter is optional.

filter supports the following OData filters:

  • eq
  • ne
  • gt
  • ge
  • lt
  • le
  • and
  • or
  • substringof
  • dr (custom eLegere OData filter)
  • multi (custom eLegere OData filter)

top

number Points how many items to fetch from the Master table. The parameter is optional.

Returns

A Promise that returns a ReadResult object.

saveMany Promise<SaveResult>

1
saveMany(items: object[]): Promise<SaveResult>

saveMany saves as row the elements of an array of items. The method saves them as row in the Master table. If the objects includes valid Id and TIMESTAMP system fields, it will update the rows identified by Id instead.

For Example:

1
2
3
4
5
const itemsToSave = [
    { Full_Name: "Jane Doe", Birth_Date: 19930703, Hourly_Cost: 150},
    { Full_Name: "John Doe", Birth_Date: 19651023, Hourly_Cost: 400}
]
const isSaveSuccessful = await employeeApp.saveMany(itemsToSave)
Parameters

items

object[] The parameter lists all the items to save. It requires the row Id and the Timestamp. The parameter constitutes a JavaScript object.

Return

A promise that returns SaveResult object.

saveManyDetail Promise<SaveResult>

1
saveManyDetail(detailName: string, masterId: number, details: object[]): Promise<SaveResult>

saveMany saves as row the elements of an array of items. The method saves them as row in the Detail table of an Application. If the objects include valid Id and TIMESTAMP system fields, it will update the rows identified by Id instead.

For Example:

1
2
3
4
5
6
const detailTableName = "Project Team"
const itemsToSave = [
    { Full_Name: "Jane Doe", Birth_Date: 19930703, Hourly_Cost: 150},
    { Full_Name: "John Doe", Birth_Date: 19651023, Hourly_Cost: 400}
]
const isSaveSuccessful = await application.saveManyDetail(detailTableName, masterRow.Id, itemsToSave)
Parameters

detailName

string Defines the specific Detail Tab containing the rows.

masterId

number Determines the Id of the Master row to associate to the item.

details

object[] Lists the item to save in the Detail table. The parameter constitutes a JavaScript object.

Return

A promise that returns SaveResult object.

saveOne Promise<SaveResult>

1
saveOne(item: object): Promise<SaveResult>

saveOne saves an item in the Master table of the Application.

For Example:

1
2
const itemToSave = { Full_Name: "Francesco_Ramanujah", Birth_Date: 19651023, Hourly_Cost: 400}
const isSaveSuccessful = await application.saveOne(itemToSave)
Parameters

item

object The parameter identifies the field and the row for the save. It must have the same fields as the row of the eLegere Master table. The parameter constitutes a JavaScript object. If the object includes valid Id and TIMESTAMP system fields, it will update the row identified by Id instead.

Returns

A promise that returns SaveResult object.

saveOneDetail Promise<SaveResult>

1
saveOneDetail(detailName: string, masterId: number, detail: object): Promise<SaveResult>

saveOneDetail() saves one item of the Detail of an Application.If the object includes valid Id and TIMESTAMP system fields, it will update the row identified by Id instead.

For Example:

1
2
3
const detailTableName = "Project Team"
const itemToSave = { Full_Name: "John Doe", Birth_Date: 19651023, Hourly_Cost: 400}
const isSaveSuccessful = await application.saveManyDetail(detailTableName, masterRow.Id, itemToSave)
Parameters

detailName

string Defines the specific Detail Tab containing the rows.

masterId

number Represents the Id of the Master row to associate a specific Detail table.

detail

object Represents the fields of the Detail to write. The parameter constitutes a JavaScript object.

Return

A promise that returns SaveResult object.

Results

ReadResult

1
type ReadResult = { Timestamp: number, Items: object[] }
The ReadResult is an object containing the keys Timestamp and Items. Timestamp represents the time when the system has retrieved the data through the service. Items represents the list of object retrieved from the database.

SaveResult

1
type SaveResult = { IsSaveSuccesfully: boolean }

The SaveResult is an object containing the key IsSaveSuccesfully. IsSaveSuccesfully is a Boolean: if TRUE, the script has saved the items with success; if FALSE, an issue occurred during the save.