Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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
I would suggest to move tcount++ to the first statement in audits each loop.
This would help when we define a logic to build retString as shown below.
results.audits.each { res ->
tcount++
// you can skip some records
if(!satisfyingMyCondition)
return
retString += "${res?.user?.id},${res?.asset?.serialNumber},${res?.category},${res.message},${res.date}\n"
}
Regards
Arunkumar D
How do I specify categories in AuditCriteria? I want to only query FILE_UPLOAD and SYSTEM_CONFIGURATION e.g.
def ac = new AuditCriteria()
ac.fromDate = Date.parse('yyyy-MM-dd', '2018-07-01')
ac.toDate = Date.parse('yyyy-MM-dd', '2018-07-05')
ac.categories = AuditCategory.SYSTEM_CONFIGURATION - ??
The following I would expect to work:
ac.categories = [ AuditCategory.FILE_UPLOAD, AuditCategory.SYSTEM_CONFIGURATION ]