Axeda Code Snippet: Getting Audit Records

    The following code snippet will retrieve a months worth of data from the system and return it as a CSV document suitable for import into your spreadsheet or reporting tool of choice.

     

    import static com.axeda.sdk.v2.dsl.Bridges.*
    import com.axeda.drm.sdk.Context
    import com.axeda.common.sdk.id.Identifier
    import com.axeda.services.v2.*
    import com.axeda.sdk.v2.exception.*
    
    def ac = new AuditCriteria()
    ac.fromDate = Date.parse('yyyy-MM-dd', '2017-03-01')
    ac.toDate   = Date.parse('yyyy-MM-dd', '2017-03-31')
    
    def retString = '' 
    
    tcount = 0
    while ( (results = auditBridge.find(ac)) != null  && tcount < results .totalCount) {
      results.audits.each { res ->
        retString += "${res?.user?.id},${res?.asset?.serialNumber},${res?.category},${res.message},${res.date}\n"
        tcount++
      }
      ac.pageNumber = ac.pageNumber + 1
    }
    
    return retString