Maximo API Client - v0.9.01
    Preparing search index...

    Class WorkOrderService

    Service for working with Maximo Work Orders Extends the base ResourceService with work order-specific operations

    Hierarchy (View Summary)

    Index

    Properties

    apiBase: string

    API base path (e.g., '/maximo/api')

    logger: ILogger
    httpClient: HttpClient

    The HTTP client for making requests

    apiHome: string

    API home path (e.g., '/maximo/api/os')

    uniqueColumn?: string

    Unique column name for the object (e.g., 'autoscriptid', 'workorderid')

    appName?: string

    Maximo App Name for generating Web URLs (e.g., 'autoscript', 'wotrack')

    objectStructure: string

    The Maximo object structure name (e.g., 'mxapiasset')

    Methods

    • Parameters

      • Optionalproperties: string | string[]

      Returns string | undefined

    • Error handler

      Parameters

      • error: any

        the error to process

      Returns never

    • Gets the unique column ID value from a resource object.

      Parameters

      Returns string | number | undefined

    • Generates a Maximo UI URL for a record.

      Parameters

      • uniqueIdValue: string | number

        The specific internal ID of the record.

      • OptionalappNameOverride: string

        Optional. Provide or override the Maximo App Name.

      • OptionalchangeTab: string

        Optional. Tab id to switch to within the app, e.g. 'relationships'.

      Returns string

    • Creates a new work order

      Parameters

      • description: string

        The work order description

      • siteId: string

        The site ID

      • OptionalworkType: string

        Optional work type

      • Optionalpriority: number

        Optional priority

      • Optionalproperties: string

        Optional properties to return in the response

      Returns Promise<WorkOrder>

      A promise resolving to the created work order

    • Assigns a work order to a person

      Parameters

      • woId: string

        The work order ID

      • personId: string

        The person ID

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Changes the status of a work order

      Parameters

      • woId: string

        The work order ID

      • status: string

        The new status

      • Optionalmemo: string

        Optional memo for the status change

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Updates the estimated and actual costs for a work order

      Parameters

      • woId: string

        The work order ID

      • estCost: number

        The estimated cost

      • OptionalactCost: number

        The actual cost

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Updates the estimated and actual hours for a work order

      Parameters

      • woId: string

        The work order ID

      • estHours: number

        The estimated hours

      • OptionalactHours: number

        The actual hours

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Finds work orders by asset

      Parameters

      • assetId: string

        The asset ID

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders by location

      Parameters

      • locationId: string

        The location ID

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders by status

      Parameters

      • status: string

        The status

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders by work type

      Parameters

      • workType: string

        The work type

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders by priority

      Parameters

      • priority: number

        The priority

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders assigned to a person

      Parameters

      • personId: string

        The person ID

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Finds work orders reported by a person

      Parameters

      • personId: string

        The person ID

      Returns Promise<WorkOrder[]>

      A promise resolving to an array of work orders

    • Add labor planning to work order

      Parameters

      • woId: string

        The work order ID

      • laborCode: string

        The labor code

      • hours: number

        The planned hours

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Add material planning to work order

      Parameters

      • woId: string

        The work order ID

      • itemNum: string

        The item number

      • storeRoom: string

        The storeroom

      • qty: number

        The quantity

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to the update response containing status and optional work order data

    • Helper method to get the work order data from an update response If the update didn't return data, this fetches the work order by ID

      Parameters

      • updateResponse: ResourceUpdateResponse<WorkOrder>

        The update response from a previous operation

      • woId: string

        The work order ID

      • Optionalproperties: string | string[]

        Optional properties to return if fetching is needed

      Returns Promise<WorkOrder>

      A promise resolving to the work order data

    Common Resource Operations

    • Executes an action on an arbitrary endpoint Useful for service endpoints that don't follow the standard resource/ID pattern Supports both GET and POST methods based on payload presence

      Parameters

      • endpoint: string

        The endpoint to call the action on (e.g., 'service/logging')

      • actionName: string

        The name of the action to execute (e.g., 'wsmethod:streamLog')

      • Optionalpayload: any

        Optional payload data for the action (if provided, uses POST, otherwise GET)

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<any>>

      A promise resolving to a response object containing success status and optional data

    primaryKeys: string[]

    Primary key columns for this resource type

    • Sets the API home path

      Parameters

      • apiHome: string

        The API home path to use

      Returns void

    • Gets the primary columns for this resource type Can be overridden by subclasses to specify their primary key columns

      Returns string[]

      Array of primary key column names

    • Encodes resource ID from primary key values Format: {col1}:{value1}|{col2}:{value2}

      Parameters

      • values: Record<string, string>

        Object containing primary key values

      Returns string

      Encoded resource ID string

    • Decodes resource ID into primary key values

      Parameters

      • resourceId: string

        Encoded resource ID string

      Returns Record<string, string>

      Object with primary key values

    • Creates a fluent builder for creating a new resource. Provides fine-grained control over the POST request headers and parameters.

      Parameters

      • data: Partial<T>

        The data for the new resource

      Returns ResourceCreate<WorkOrder>

      A ResourceCreate builder instance

      const asset = await client.asset
      .createResource({ assetnum: 'A001', description: 'New Asset' })
      .returnProperties(['assetnum', 'status'])
      .suppressEvents()
      .execute();
    • Creates a fluent builder for updating an existing resource. Provides fine-grained control over the PATCH request headers and parameters.

      Parameters

      • id: string

        The ID of the resource to update

      • data: Partial<T>

        The data to update

      Returns ResourceUpdate<WorkOrder>

      A ResourceUpdate builder instance

      const result = await client.asset
      .updateById('12345', { description: 'Updated' })
      .useMergePatch()
      .suppressEvents()
      .execute();
    • Creates a new resource (Simple Version)

      Parameters

      • data: Partial<T>

        The data for the new resource

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response (string or string array)

      • OptionalgetCreatedResult: boolean

        If true, fetches and returns the created resource after creation (default: false)

      Returns Promise<WorkOrder>

      A promise resolving to the created resource

    • Creates a new resource

      Parameters

      • data: Partial<T>

        The data for the new resource

      • Optionalparams: Record<string, string>

        Optional query parameters (e.g., { ignorecollectionref: '1' })

      • Optionalheaders: Record<string, string>

        Optional HTTP headers (e.g., { properties: 'field1,field2', 'x-allow-events': '0' })

      Returns Promise<WorkOrder>

      A promise resolving to the created resource

    • Updates an existing resource (simple version)

      Parameters

      • id: string

        The ID of the resource to update

      • data: Partial<T>

        The data to update

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response (string or string array)

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data

    • Updates an existing resource

      Parameters

      • id: string

        The ID of the resource to update

      • data: Partial<T>

        The data to update

      • Optionalparams: Record<string, string>

        Optional query parameters

      • Optionalheaders: Record<string, string>

        Optional HTTP headers (e.g., { patchtype: 'MERGE', 'x-allow-events': '0' })

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data

    • Merges changes into an existing resource (simple version)

      Parameters

      • id: string

        The ID of the resource to update

      • data: Partial<T>

        The data to merge, including child objects

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response (string or string array)

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data

    • Merges changes into an existing resource (e.g., for updating child objects) Uses MERGE patch type to avoid deleting unspecified child objects

      Parameters

      • id: string

        The ID of the resource to update

      • data: Partial<T>

        The data to merge, including child objects

      • Optionalparams: Record<string, string>

        Optional query parameters

      • Optionalheaders: Record<string, string>

        Optional HTTP headers

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data

    • Synchronizes a resource: Creates it if it doesn't exist (based on primary keys), or updates it if it does. Uses the SYNC method override.

      Parameters

      • data: Partial<T>

        The data for the resource, including primary key fields.

      • Optionalparams: Record<string, string>

        Optional query parameters

      • Optionalheaders: Record<string, string>

        Optional HTTP headers (e.g., { patchtype: 'MERGE' })

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data.

    • Deletes a resource

      Parameters

      • idOrResource: string | Partial<WorkOrder> | undefined

        The ID of the resource to delete or the resource object itself

      • Optionalparams: Record<string, string>

        Optional query parameters

      • Optionalheaders: Record<string, string>

        Optional HTTP headers

      Returns Promise<void>

      A promise that resolves when the resource is deleted

    • Creates a fluent builder for deleting a single resource by ID. Provides fine-grained control over the DELETE request headers.

      Parameters

      • id: string

        The ID of the resource to delete

      Returns ResourceDelete<WorkOrder>

      A ResourceDelete builder instance

      await client.asset
      .deleteById('12345')
      .withTransactionId('unique-tx-id')
      .suppressEvents()
      .execute();
    • Retrieves a resource by its ID

      Parameters

      • id: string

        The ID of the resource to retrieve

      • Optionalselect: string | string[]

        Optional oslc.select to return in the response (string or string array)

      Returns Promise<WorkOrder>

      A promise resolving to the resource

    • Creates a fluent builder for fetching a single resource by ID. Provides fine-grained control over the GET request parameters.

      Parameters

      • id: string

        The ID of the resource to fetch

      Returns ResourceFetch<WorkOrder>

      A ResourceFetch builder instance

      const asset = await client.asset
      .fetch('12345')
      .properties(['assetnum', 'description', 'status'])
      .inlineDoc(true)
      .dropNulls(false)
      .execute();
    • Counts resources matching the given condition

      Parameters

      • OptionalwhereOrBuilder: string | QueryBuilder<WorkOrder>

        Optional OSLC where condition or a QueryBuilder instance

      Returns Promise<number>

      A promise resolving to the count

    • Finds a resource by its ID

      Parameters

      • id: string

        The ID of the resource

      • Optionalproperties: string | string[]

        Optional properties to return (string or string array)

      Returns Promise<WorkOrder>

      A promise resolving to the resource

    • Finds distinct values for a field

      Parameters

      • fieldOrBuilder: string | QueryBuilder<WorkOrder>

        The field to get distinct values for or a QueryBuilder with distinct field

      • Optionalwhere: string

        Optional OSLC where condition (ignored if fieldOrBuilder is a QueryBuilder)

      Returns Promise<any[]>

      A promise resolving to an array of distinct values

    • Retrieves allowed actions for a specific resource

      Parameters

      • id: string

        The ID of the resource to get allowed actions for

      Returns Promise<WorkOrder>

      A promise resolving to the resource with allowed actions information

    • Executes an action on a specific resource Supports both GET and POST methods based on payload presence

      Parameters

      • id: string

        The ID of the resource to execute the action on

      • actionName: string

        The name of the action to execute

      • Optionalpayload: any

        Optional payload data for the action (if provided, uses POST, otherwise GET)

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<WorkOrder>>

      A promise resolving to a response object containing success status and optional data

    • Executes a global action on the object structure (not tied to a specific resource)

      Parameters

      • actionName: string

        The name of the action to execute

      • Optionalpayload: any

        Optional payload data for the action (if provided, uses POST, otherwise GET)

      • OptionalreturnProperties: string | string[]

        Optional properties to return in the response

      Returns Promise<ResourceUpdateResponse<any>>

      A promise resolving to a response object containing success status and optional data

    Constructors

    Report Operations

    • Generates a BIRT report

      Parameters

      • reportName: string

        The name of the report to generate (e.g., 'woprint.rptdesign')

      • format: string = 'pdf'

        The output format (default: 'pdf'). Other options: 'xls', 'html', etc.

      • OptionaladditionalParams: Record<string, any>

        Optional additional parameters (e.g., oslc.where, or report parameters)

      Returns Promise<any>

      A promise resolving to the report content as a buffer (or appropriate type based on environment)