Skip to content

Instantly share code, notes, and snippets.

Created October 31, 2018 19:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
function (result) {
var workflowdefinition = JSON.parse(result.msdyncrm_workflowdefinition);
// Retrieve nodes related to provided component.
var emails = rootActivityFilter(workflowdefinition, "Email");
var segemnts = rootActivityFilter(workflowdefinition, "Segment");
var events = rootActivityFilter(workflowdefinition, "Event");
// To get all the record's GUID & metadata use .toArray()
var emailRecords = emails.where(x => x[0].ItemId != null).toArray();
// If you want just number of records .count() can be used
var eventCount = events.where(x => x[0].ItemId != null).count();
function (error) {
// funtion to filter out only data node for provided element
function rootActivityFilter(workflowdefinition, element) {
return Enumerable
.where(w => w.ActivityTypeId == element)
.select(s => s.Properties.Items);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment