I'm using some javascript code to retrieve the workflow definitions on my site:
var context = SP.ClientContext.get_current();
var web = _context.get_web();
var serviceManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);
var deploymentService = serviceManager.getWorkflowDeploymentService();
var definitions = deploymentService.enumerateDefinitions();
context.load(definitions);
return context.executeQuery()
.then(function(){
console.log(definitions);
var enumDefs = definitions.getEnumerator();
while(enumDefs.moveNext()){
....
});
BTW I've wrapped executeQueryAsync with jQuery Deferred so my JSOM code can resemble my REST code. Here is a John Liu's blog on how to do that.
This is working and I can clunkily iterate my way through the list. But I really, really dislike using the SP complex types and all their methods.
In the browser I see that a nice simple json array is being send back as the response. Is there anyway I can just get that?
Is there some way to easily change all the information that comes back into a json object?
var wfarray []; var enumDefs = definitions.getEnumerator(); while(enumDefs.moveNext()){ var currentwf = enumDefs.get_current(); wfarray.push(currentwf); } //do something with wfarray;