Compute Dates from Schedules
This workflow is included in the Scheduling package.
Description
Outputs dates matching schedules given a range specified by start date and an end date.
Properties
This workflow has the following properties.
| Property | Value |
|---|---|
| Name | Compute Dates from Schedules |
| Code | workflows_computeDatesFromSchedules_8e51c150022e2c7e705e9223 |
| Type | Workflow |
| Context | Package |
| Enabled | Yes |
| Tags | Causeway |
| Log retention | 7 days |
Trigger
A user triggers this workflow on demand, or another workflow runs it (via an MWR). It works on the items of the design below.
| Property | Value |
|---|---|
| Workflow type | Manual workflow |
| Applies to | Schedules |
| Output mode | ManyItems (Runs once for all items) |
| Parameters design | MTP - Compute Dates from Schedules |
| Output action | The Output action highlighted in the diagram below |
Actions
This workflow runs 16 actions, in the order shown in this simplified diagram. Select an MWR action to open the workflow it runs. Every action's full settings are in the configuration below.
Configuration
The full configuration of this workflow, including every action's parameters.
Show configuration (673 lines)
{
"trigger": {
"dodiCode": "designInterfaces_schedule_8bbf2c5dac22df0ab9d7e055",
"parametersDesignCode": "designs_computeDatesFromSchedules_8e51c150022e2c7e705e9223",
"outputActionId": "802e15d9cefcb0aa6b0c36b2",
"outputMode": "ManyItems"
},
"actions": [
{
"actionId": "87bc714d10eaaf91be32b0e2",
"designCode": "designs_workflowRelationAction",
"description": "Get parent schedulable",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root^attributes_schedulableTaskSchedules_86d15a122f4aaa1b57cedbf4<designInterfaces_schedulable_801adccd0a05b30647df41c6>",
"attributeType": "String"
}
}
],
"variables": [],
"actions": [
{
"actionId": "87bc714d10eaaf91be31a0e3",
"designCode": "designs_workflowRelationAction",
"description": "Get related taskAssignable(s)",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsStandardPathId",
"value": "66f56ab51797b9a782228000",
"attributeType": "String"
}
}
],
"variables": [],
"actions": [
{
"actionId": "87bc714d10eaaf91be34a0e4",
"designCode": "designs_workflowRelationAction",
"description": "Get all tasks",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_tasksAssignableTasks",
"attributeType": "String"
}
}
],
"variables": [],
"actions": []
}
]
}
]
},
{
"actionId": "822384849368da183bb43721",
"designCode": "designs_workflowQueryAction",
"comments": "Query related tasks connected to a specific taskType",
"variables": [
{
"name": "tasksCouldBeEmpty",
"value": {
"outputAction": "87bc714d10eaaf91be34a0e4",
"itemValue": {
"property": "ItemId"
},
"outputMode": "Input"
}
},
{
"name": "filteredTasks",
"value": {
"script": "return tasksCouldBeEmpty.Any() ? Set<AId>(tasksCouldBeEmpty) : Set<AId>(AlloyId(\"5c8bdfc18ae862230019dc21\"));"
},
"attributeType": "Link"
},
{
"name": "relatedTaskType",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_scheduleTasksToGenerate_8e052b8307c10ea8ae43b4ec"
}
}
}
],
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowQueryActionsSingleInstance",
"value": false
}
},
{
"attribute": {
"attributeCode": "attributes_workflowQueryActionsAqsQuery",
"value": {
"type": "Query",
"properties": {
"dodiCode": "designInterfaces_scheduledTask_8465d419467667a08a6b03cf",
"collectionCode": "Live",
"parameters": [
{
"name": "filteredTasks",
"type": "AlloyId"
},
{
"name": "relatedTaskType",
"type": "AlloyId"
}
],
"attributes": [
"attributes_itemsTitle",
"attributes_itemsSubtitle"
]
},
"children": [
{
"type": "And",
"children": [
{
"type": "Equals",
"children": [
{
"type": "ItemProperty",
"properties": {
"itemPropertyName": "itemId"
}
},
{
"type": "AlloyId",
"properties": {
"parameterName": "filteredTasks"
}
}
]
},
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_tasksWithTaskTypesTaskType"
}
},
{
"type": "AlloyId",
"properties": {
"parameterName": "relatedTaskType"
}
}
]
}
]
}
]
}
}
}
],
"actions": []
},
{
"actionId": "802e15d9cefcb0aa6b0c36b2",
"designCode": "designs_workflowOutputAction",
"comments": "Compute schedule's matching dates",
"parameters": [
{
"attributeCode": "attributes_workflowOutputActionData",
"value": {
"script": "var inclusivePeriodicitiesDtmsEnum = Variables.inclusivePeriodicitiesDtmsRaw.AllValues.Values.Select(x => x.SingleValue.Value).OrderBy(i => i).ToList();\r\n var exclusivePeriodicitiesDtmsEnum = Variables.exclusivePeriodicitiesDtmsRaw.AllValues.Values.Select(x => x.SingleValue.Value).OrderBy(i => i).ToList();\r\n\r\n var inclusiveScheduleDtmsEnum = scheduleDtmsJson?[\"include\"]?.Values<DateTime>().OrderBy(i => i).ToList() ?? List<DateTime>();\r\n var exclusiveScheduleDtmsEnum = scheduleDtmsJson?[\"exclude\"]?.Values<DateTime>().OrderBy(i => i).ToList() ?? List<DateTime>();\r\n\r\n var inclusiveDtms = inclusivePeriodicitiesDtmsEnum.Union(inclusiveScheduleDtmsEnum);\r\n var exclusiveDtms = exclusivePeriodicitiesDtmsEnum.Union(exclusiveScheduleDtmsEnum);\r\n var lowerLimit = startsOn.Value > generationStart.Value ? startsOn.Value : generationStart.Value;\r\n var upperLimit = endsOn.Value < generationEnd.Value ? endsOn.Value : generationEnd.Value;\r\n\r\n var selectedDtms = inclusiveDtms.Except(exclusiveDtms).Distinct().Where(d => d >= lowerLimit && d < upperLimit).OrderBy(dt => dt).ToList();\r\n\r\n return Json(new { items = selectedDtms.Select(s => new { attributes_computeDatesFromSchedulesOutputDateOccurance_8ad5639456d15a25d67516c5 = s }).ToArray() });"
},
"attributeType": "Json"
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionDodiCode",
"value": "designs_computeDatesFromSchedulesOutput_8c05e8b036adaaba582068a2"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionSingleInstance",
"value": false
}
}
],
"variables": [
{
"name": "inclusivePeriodicitiesDtmsRaw",
"value": {
"outputAction": "8d2cf34a3068f911adc77e14",
"outputMode": "Input",
"itemValue": {
"attributeCode": "attributes_computeDatesFromPeriodicitiesOutputDateOccurance_8ad5639456d15a25d67516c5"
}
},
"attributeType": "Date"
},
{
"name": "exclusivePeriodicitiesDtmsRaw",
"value": {
"outputAction": "82b37c925a78e7d536ff6838",
"outputMode": "Input",
"itemValue": {
"attributeCode": "attributes_computeDatesFromPeriodicitiesOutputDateOccurance_8ad5639456d15a25d67516c5"
}
},
"attributeType": "Date"
},
{
"name": "scheduleDtmsJson",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_scheduleDates_8de88b7173c8a0a7ca743e7e"
}
},
"attributeType": "Json"
},
{
"name": "startsOn",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_scheduleStartsOn_8938a2342563580acb7d5ca5"
}
}
},
{
"name": "endsOn",
"value": {
"inputParent": 0,
"itemValue": {
"attributeCode": "attributes_scheduleEndsOn_8f3ddb33870afa31cde2e449"
}
}
},
{
"name": "generationStart",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeStart_800d6f68feb01147ef0d2035",
"inputMode": "Each"
}
},
{
"name": "generationEnd",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeEnd_81c4dd81e998b56ddfe158ab",
"inputMode": "Each"
}
}
],
"actions": []
},
{
"actionId": "681b20a61337203e57072f8a",
"designCode": "designs_workflowFilterAction",
"description": "if it's a cyclical schedule....",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowFilterActionsAqsQuery",
"value": {
"type": "Query",
"properties": {
"dodiCode": "designInterfaces_standardCyclicalSchedule_8df406ac30b303672ed6d907",
"collectionCode": "Live",
"attributes": [
"attributes_itemsTitle",
"attributes_itemsSubtitle"
]
}
},
"attributeType": "Aqs"
}
}
],
"variables": [],
"actions": [
{
"actionId": "681b20a61337203e57072f8b",
"designCode": "designs_workflowRelationAction",
"comments": "Navigate to Inclusive Periodicities",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_standardCyclicalScheduleInclusivePeriodicities_68132ec89b8145b312072f8a",
"attributeType": "String"
}
}
],
"variables": [],
"actions": []
},
{
"actionId": "68247ac0f472468c915d6db0",
"designCode": "designs_workflowRelationAction",
"comments": "Navigate to Exclusive Periodicities",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_standardCyclicalScheduleExclusivePeriodicities_68132ec89b8145b312072f8b",
"attributeType": "String"
}
}
],
"variables": [],
"actions": []
}
]
},
{
"actionId": "681b20a61337203e57072f8c",
"designCode": "designs_workflowFilterAction",
"description": "if it's a relative schedule....",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowFilterActionsAqsQuery",
"value": {
"type": "Query",
"properties": {
"dodiCode": "designInterfaces_relativeDateSchedule_81e19cdae3c5d9df4917200e",
"collectionCode": "Live",
"attributes": [
"attributes_itemsTitle",
"attributes_itemsSubtitle"
]
}
},
"attributeType": "Aqs"
}
}
],
"variables": [],
"actions": [
{
"actionId": "681b20a61337203e57072f8d",
"designCode": "designs_workflowRelationAction",
"comments": "Navigate to Inclusive Periodicities",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_relativeDateScheduleInclusivePeriodicities_68132ef2e1b1a16829072f8a",
"attributeType": "String"
}
}
],
"variables": [],
"actions": []
},
{
"actionId": "68247acb51ceab2046261871",
"designCode": "designs_workflowRelationAction",
"comments": "Navigate to Exclusive Periodicities",
"parameters": [
{
"attribute": {
"attributeCode": "attributes_workflowRelationActionsAqsPath",
"value": "root.attributes_relativeDateScheduleExclusivePeriodicities_68132ef2e1b1a16829072f8b",
"attributeType": "String"
}
}
],
"variables": [],
"actions": []
}
]
},
{
"actionId": "878f54e1737a5da563d263e3",
"designCode": "designs_workflowOutputAction",
"comments": "Filter out relativeDateSchedules with uncompleted task",
"parameters": [
{
"attributeCode": "attributes_workflowOutputActionItems",
"attributeType": "Link",
"value": {
"script": "return isRelativeSchedule.Value && hasUncompletedTask.Value ? (AId?)null : thisItem;"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionDodiCode",
"value": "designInterfaces_schedule_8bbf2c5dac22df0ab9d7e055"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionSingleInstance",
"value": false
}
}
],
"variables": [
{
"name": "interfacesImplemented",
"value": {
"inputParent": 0,
"itemValue": {
"property": "Implements"
}
},
"attributeType": "String"
},
{
"name": "isRelativeSchedule",
"value": {
"script": "return Variables.interfacesImplemented.AllValues.Values.Any(x => x.SingleValue.Equals(\"designInterfaces_relativeDateSchedule_81e19cdae3c5d9df4917200e\"));"
},
"attributeType": "Boolean"
},
{
"name": "thisItem",
"value": {
"inputParent": 0,
"itemValue": {
"property": "ItemId"
}
},
"attributeType": "Link"
},
{
"name": "completionDates",
"value": {
"outputAction": "822384849368da183bb43721",
"itemValue": {
"attributeCode": "attributes_tasksCompletionTime"
},
"outputMode": "Input"
},
"attributeType": "DateTime"
},
{
"name": "hasUncompletedTask",
"value": {
"script": "var list = Variables.completionDates?.AllValues.Values.Select(x => x.SingleValue).OrderBy(x => x == null).ThenBy(x => x).ToList(); return (list != null && list.Any() && list.Last() == null);"
},
"attributeType": "Boolean"
},
{
"name": "lastCompletion",
"value": {
"script": "var list = Variables.completionDates?.AllValues.Values.Select(x => x.SingleValue).OrderBy(x => x == null).ThenBy(x => x).ToList(); return (list != null && list.Any()) ? list.Last() : (DateTime?)null;"
},
"attributeType": "DateTime"
}
],
"actions": [
{
"actionId": "84397dc7714c2c42cf26255f",
"designCode": "designs_workflowOutputAction",
"comments": "Compute schedule's matching dates",
"parameters": [
{
"attributeCode": "attributes_workflowOutputActionItems",
"value": {
"script": "cyclicalPeriodicityItemId.Concat(relativePeriodicityItemId)"
},
"attributeType": "Json"
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionDodiCode",
"attributeType": "String",
"value": "designInterfaces_periodicity_68109e5096e0ec0345072f8a"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionSingleInstance",
"value": false
}
}
],
"variables": [
{
"name": "cyclicalPeriodicityItemId",
"value": {
"outputAction": "681b20a61337203e57072f8b",
"itemValue": {
"property": "ItemId"
},
"outputMode": "Input"
},
"attributeType": "Json"
},
{
"name": "relativePeriodicityItemId",
"value": {
"outputAction": "681b20a61337203e57072f8d",
"itemValue": {
"property": "ItemId"
},
"outputMode": "Input"
},
"attributeType": "Json"
}
],
"actions": [
{
"actionId": "8d2cf34a3068f911adc77e14",
"designCode": "designs_computeDatesFromPeriodicities_874950917130ef4b6ae2e28c",
"comments": "Get periodicities next dates",
"parameters": [
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesPeriodStartDate_682622f2a2dfdc1bec786d3e",
"value": {
"script": "Date(lastCompletion)"
},
"attributeType": "Date"
},
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesDateRangeStart_800d6f68feb01147ef0d2035",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeStart_800d6f68feb01147ef0d2035",
"inputMode": "Each"
},
"attributeType": "Date"
},
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesDateRangeEnd_81c4dd81e998b56ddfe158ab",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeEnd_81c4dd81e998b56ddfe158ab",
"inputMode": "Each"
},
"attributeType": "Date"
},
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesLimit_8f4d17da8e3a79f4d3fa840b",
"value": {
"script": "return !isRelativeSchedule.Value ? (int?)null : 1.0;"
},
"attributeType": "Number"
}
],
"variables": [
{
"name": "lastCompletion",
"value": {
"outputAction": "878f54e1737a5da563d263e3",
"itemValue": {
"variableName": "lastCompletion"
},
"outputMode": "Input"
},
"attributeType": "DateTime"
},
{
"name": "isRelativeSchedule",
"value": {
"outputAction": "878f54e1737a5da563d263e3",
"itemValue": {
"variableName": "isRelativeSchedule"
},
"outputMode": "Input"
},
"attributeType": "Boolean"
}
],
"actions": []
}
]
},
{
"actionId": "6823422354733fdfa0e8c74a",
"designCode": "designs_workflowOutputAction",
"description": "Outputs the potential Exclusive Periodicities",
"parameters": [
{
"attributeCode": "attributes_workflowOutputActionItems",
"attributeType": "Link",
"value": {
"script": "cyclicalExclusive.Concat(relativeExclusive)"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionDodiCode",
"value": "designInterfaces_periodicity_68109e5096e0ec0345072f8a"
}
},
{
"attribute": {
"attributeCode": "attributes_workflowOutputActionSingleInstance",
"value": false
}
}
],
"variables": [
{
"name": "cyclicalExclusive",
"value": {
"outputAction": "68247ac0f472468c915d6db0",
"itemValue": {
"property": "ItemId"
},
"outputMode": "Input"
},
"attributeType": "String"
},
{
"name": "relativeExclusive",
"value": {
"outputAction": "68247acb51ceab2046261871",
"itemValue": {
"property": "ItemId"
},
"outputMode": "Input"
},
"attributeType": "String"
}
],
"actions": [
{
"actionId": "82b37c925a78e7d536ff6838",
"designCode": "designs_computeDatesFromPeriodicities_874950917130ef4b6ae2e28c",
"comments": "Get periodicities next dates",
"parameters": [
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesPeriodStartDate_682622f2a2dfdc1bec786d3e",
"value": {
"script": "Date(lastCompletion)"
},
"attributeType": "Date"
},
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesDateRangeStart_800d6f68feb01147ef0d2035",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeStart_800d6f68feb01147ef0d2035",
"inputMode": "Each"
},
"attributeType": "Date"
},
{
"attributeCode": "attributes_computeDatesFromPeriodicitiesDateRangeEnd_81c4dd81e998b56ddfe158ab",
"value": {
"parameterCode": "attributes_computeDatesFromSchedulesDateRangeEnd_81c4dd81e998b56ddfe158ab",
"inputMode": "Each"
},
"attributeType": "Date"
}
],
"variables": [
{
"name": "lastCompletion",
"value": {
"outputAction": "878f54e1737a5da563d263e3",
"itemValue": {
"variableName": "lastCompletion"
},
"outputMode": "Input"
},
"attributeType": "DateTime"
}
],
"actions": []
}
]
}
]
}
]
}