cityworks
    Preparing search index...

    cityworks

    Cityworks node.js API wrapper

    This API wrapper for Cityworks follows the Cityworks release schedule as closely as possible. Functionality may be missing depending on necessity or use.

    Require the class:

      const cw = require('cityworks')
    

    or

      import * as cw from 'cityworks'
    

    Instantiate the Class for the instance of Cityworks available given a domain:

      cw.Cityworks.configure('cwoffice.domain.tld', {path: 'cityworks', version: 15})
    

    or

      cw.Cityworks.configure('cw.domain.tld', {path: 'cityworks', version: 23});
    

    Authenticate with the Cityworks install:

      cw.Cityworks.authenticate('myuser', 'mypassword').then(resp => {}).catch(error => {
        console.log(error.message)
      })
    

    Get the currently valid token in order to store it in a session or cookie:

      cw.Cityworks.getToken()
    

    Provide a saved token instead of the standard u/p auth:

      cw.Cityworks.setToken('mytoken')
    

    Access the primary AMS (Inspection, WorkOrder, & Service Request) & PLL object libraries like so:

      cw.inspection.methodHere().then(resp => {})
      cw.workorder.methodHere().then(resp => {})
      cw.request.methodHere().then(resp => {})
      cw.briefcase.methodHere().then(resp => {})
    

    Some of the methods are general or top-level, and so, are accessed separately are at the same level of reference from the cityworks object:

    General methods including authentication:

      cw.general.methodHere().then(resp => {})
    

    Message queue methods for examining, processing, and troubleshooting webhooks and activity events:

      cw.message_queue.methodHere().then(resp => {})
    

    Activity link for linking one node/object to another:

      cw.activity_link.methodHere().then(resp => {})
    

    Mapping and GIS methods not specific to a single object type:

      cw.gis.methodHere().then(resp => {})
    

    General query methods:

      cw.query.methodHere().then(resp => {})
    

    (Deprecated) General search methods:

      cw.search.methodHere().then(resp => {})
    

    For the sake of organizing some of the other methods needed by the primary and secondary libraries, there are also objects and methods accessed within those main libraries:

    For PLL case financial actions:

      cw.briefcase.financial.methodHere().then(resp => {})
    

    For PLL case data details & data groups:

      cw.briefcase.data.methodHere().then(resp => {})
    

    For PLL case workflow and task actions:

      cw.briefcase.workflow.methodHere().then(resp => {})
    

    For PLL administration actions:

      cw.briefcase.admin.methodHere().then(resp => {})
    

    For any object in Cityworks which can be commented on, use the Comments class via the class the comment is to be made on:

      cw.briefcase.comment.add(CaObjectIdGoesHere, "Comment goes here").then(resp => {})
    
      cw.workorder.comment.add(WorkOrderSIDGoesHere, "Comment goes here").then(resp => {})
    
      cw.request.comment.add(RequestIDGoesHere, "Comment goes here").then(resp => {})
    

    Customer calls belong to an existing service request. The CustomerCall class is a subclass of Request, available as cw.request.customerCall:

      cw.request.customerCall.addToRequest(RequestIDGoesHere, {FirstName: 'Pat', LastName: 'Smith', HomePhone: '555-0100'}).then(resp => {})
    
      cw.request.customerCall.getByRequestId(RequestIDGoesHere).then(resp => {})
    
      cw.request.customerCall.updateCall(IncidentNumGoesHere, {Email: 'pat@example.com'}).then(resp => {})
    

    You can also pass customer call data straight through request.create and request.update. The resolved request gets a CustomerCalls array:

      cw.request.create({ProblemSid: 309}, {FirstName: 'Pat', LastName: 'Smith'}).then(sr => { sr.CustomerCalls })
    
      // A call with an IncidentNum updates that call; without one, an existing call on the request with a matching phone number or email is updated; otherwise a new call is added
      cw.request.update({RequestId: 123, Description: 'More info'}, [{IncidentNum: 456, Email: 'pat@example.com'}, {FirstName: 'Lee'}])
    
      // The same caller phones in again: create a NEW customer call, never updating their previous one
      cw.request.update({RequestId: 123}, {FirstName: 'Pat', LastName: 'Smith', Comments: 'Called again'}, {newCall: true})
    

    {newCall: true} ignores any IncidentNum and phone/email matching (e.g. when you copied data from a previous call). Note any DateTimeCall you copy over will be sent as well.

    For any object in Cityworks which has attachments, (including cases as CaRelDocs), use the Attachments class via the class the attachment is to be made on:

      cw.briefcase.attachment.add(CaObjectIdGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
    
      cw.workorder.attachment.add(WorkOrderSIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
    
      cw.request.attachment.add(RequestIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
    
      cw.inspection.attachment.add(InspectionIDGoesHere, path.join('uploads', 'filename.pdf')).then(resp => {})
    
      cw.activity_link.add(source_type, source_sid, destination_type, destination_sid)