Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Xrm.WebApi.retrieveRecord(
"msdyncrm_customerjourney",
"945a02a0-b2db-e811-a967-000d3af29269",
"$select=msdyncrm_workflowdefinition").then(
function (result) {
debugger;
console.log(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) {
console.log(error.message);
}
);
// funtion to filter out only data node for provided element
function rootActivityFilter(workflowdefinition, element) {
return Enumerable
.from(workflowdefinition)
.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
You can’t perform that action at this time.