Categorie: reference Bijgewerkt: 2026-04-08 actionfield workflow actionfield1143

ActionField1143

Beschrijving: Change DesiredProgressStatus and Status for all WorkOrderScheduleJobs of the current WorkOrderSchedule (via dialog). Custom: Nee

Propertiesbewerken

Property Type Accessor
WorkOrderSchedule WorkOrderSchedule Root

XMLbewerken

<Workflow Name="ActionField1143" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Change DesiredProgressStatus and Status for all WorkOrderScheduleJobs of the current WorkOrderSchedule (via dialog).</Description>
	<Properties>
		<Property	Name="WorkOrderSchedule"			Type="WorkOrderSchedule"			Accessor="Root"		Direction="In" />

		<Property	Name="InvalidProgressStatusCount"	Type="Int64"						Accessor="Internal"						Default="0" />
		<Property	Name="IsTransitionAuthorized"		Type="Boolean"						Accessor="Internal" />
		<Property	Name="IsTransitionValid"			Type="Boolean"						Accessor="Internal" />
		<Property	Name="JobsCount"					Type="Int64"						Accessor="Internal" />
		<Property	Name="LastValidationRuleMessage"	Type="String"						Accessor="Internal" />
		<Property	Name="ProgressStatusFlows"			Type="List[ProgressStatusFlow]"		Accessor="Internal" />
		<Property	Name="QueryResultJobs"				Type="QueryResult"					Accessor="Internal" />
		<Property	Name="SelectedProgressStatus"		Type="ProgressStatus"				Accessor="Internal" />
		<Property	Name="SqlWhereClause"				Type="UltimoString"					Accessor="Internal" />
		<Property	Name="UnauthorizedTransitions"		Type="List[ProgressStatus]"			Accessor="Internal" />
		<Property	Name="ValidationRulesSummary"		Type="String"						Accessor="Internal" />
		<Property	Name="WorkOrderScheduleJobs"		Type="List[WorkOrderScheduleJob]"	Accessor="Internal" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

		<Transaction>
			<GetCount Name="Count number of jobs linked to WorkOrderSchedule" Type="WorkOrderScheduleJob" OutputProperty="${JobsCount}">
				<Filters>
					<PropertyFilter	PropertyName="Id.WorkOrderSchedule"	Operator="="		PropertyValue="${WorkOrderSchedule}" />
				</Filters>
			</GetCount>

			<Validation Name="ValidateJobsLinked" Condition="${JobsCount} &gt; 0" MessageCode="2266" />

			<Comment><![CDATA[
				SELECT PrsfAvailableNextPrsId
					FROM dba.ProgressStatusFlow
					JOIN dba.ProgressStatus ON ProgressStatus.PrsId = ProgressStatusFlow.Id.ProgressStatusNextAvailable.Id
					WHERE ProgressStatus.PrsNextRecStatus IN (4,8192,16,32) AND
						PrsfPrsId IN (

							SELECT JobPrsId
								FROM dba.Job
								WHERE JobId IN (

									SELECT WosjdJobId
										FROM dba.WoSchedJobDet
										WHERE WosjdWosId = ${WorkOrderSchedule.Id}))
				]]></Comment>

			<GetList Name="Get list of next progress statuses" Type="ProgressStatusFlow" OutputProperty="${ProgressStatusFlows}" OrderBy="Id" OrderDirection="Ascending">
				<Joins>
					<Join	Name="Id.ProgressStatusNextAvailable"	Alias="progressStatus"		Type="InnerJoin" />
					<Join	Name="AuthorizationGroups"				Alias="authorizationGroups"	Type="LeftOuterJoin" />
					<Join	Name="authorizationGroups.Id.Group"		Alias="group"				Type="LeftOuterJoin" />
					<Join	Name="group.GroupUsers"					Alias="groupuser"			Type="LeftOuterJoin" />
				</Joins>
				<Filters>
					<InFilter PropertyName="progressStatus.NextStatus" Values="JobStatus.Active,JobStatus.Postponed,JobStatus.Finished,JobStatus.Closed,JobStatus.Completed" />
					<InFilter PropertyName="Id.ProgressStatus">
						<Subquery Type="Job">
							<Filters>
								<InFilter PropertyName="Id">
									<Subquery Type="WorkOrderScheduleJob">
										<Filters>
											<PropertyFilter	PropertyName="Id.WorkOrderSchedule"	Operator="="		PropertyValue="${WorkOrderSchedule}" />
										</Filters>
										<Properties>
											<Property Name="Id.Job.Id" Alias="Id" Type="Property" />
										</Properties>
									</Subquery>
								</InFilter>
							</Filters>
							<Properties>
								<Property Name="ProgressStatus" Alias="progressStatus" Type="Property" />
							</Properties>
						</Subquery>
					</InFilter>
					<CombinedFilter FilterOperator="Or">
						<PropertyFilter	PropertyName="authorizationGroups.Id"	Operator="="		PropertyValue="Empty" />
						<PropertyFilter	PropertyName="groupuser.Id.User.Id"		Operator="="		PropertyValue="#{User.Id}" />
					</CombinedFilter>
				</Filters>
			</GetList>

			<Validation Name="ValidateProgressStatusFlowsFound" Condition="${ProgressStatusFlows.Count} &gt; 0" MessageCode="2267" />
			<Assign Name="Set WHERE clause with ProgressStatus ids" Property="${SqlWhereClause}" Value="PrsId IN (#foreach(${ProgressStatusFlow} in ${ProgressStatusFlows})#each'${ProgressStatusFlow.Id.ProgressStatusNextAvailable.Id}'#between,#end)" />
		</Transaction>

		<SystemDialog Name="DialogSelectProgressStatus" DialogName="SelectDomainObject">
			<Parameter	Name="EntityName"					Direction="In"		Value="ProgressStatus" />
			<Parameter	Name="SelectionListConfiguration"	Direction="In"		Value="Desired" />
			<Parameter	Name="SqlWhereClause"				Direction="In"		Value="${SqlWhereClause}" />
			<Parameter	Name="DomainObject"					Direction="Out"									OutputProperty="${SelectedProgressStatus}" />
		</SystemDialog>

		<Transaction>
			<Query Name="Get list of jobs grouped by unique ProgressStatuses" Type="Job" OrderBy="ProgressStatus" OrderDirection="Ascending" OutputProperty="${QueryResultJobs}">
				<Filters>
					<InFilter PropertyName="Id">
						<Subquery Type="WorkOrderScheduleJob">
							<Filters>
								<PropertyFilter	PropertyName="Id.WorkOrderSchedule"	Operator="="		PropertyValue="${WorkOrderSchedule}" />
							</Filters>
							<Properties>
								<Property Name="Id.Job.Id" Alias="Id" Type="Property" />
							</Properties>
						</Subquery>
					</InFilter>
				</Filters>
				<Properties>
					<Property Name="ProgressStatus" Alias="ProgressStatus" Type="GroupProperty" />
				</Properties>
			</Query>

			<ForEach Name="For each unique ProgressStatus (grouped Job)" In="${QueryResultJobs}" As="Job">
				<Command Name="IsProgressStatusTransitionAuthorized" CommandName="IsProgressStatusTransitionAuthorized">
					<Parameter	Name="NewProgressStatus"					Direction="In"		Value="${SelectedProgressStatus}" />
					<Parameter	Name="OldProgressStatus"					Direction="In"		Value="${Job.ProgressStatus}" />
					<Parameter	Name="IsProgressStatusTransitionAuthorized"	Direction="Out"											OutputProperty="${IsTransitionAuthorized}" />
				</Command>

				<Choose Name="Check the transition">
					<When Name="When the transition is valid and authorized" Condition="${IsTransitionAuthorized} == True">
						<GetList Name="Get all WorkOrderScheduleJobs with this ProgressStatus" Type="WorkOrderScheduleJob" OutputProperty="${WorkOrderScheduleJobs}" OrderBy="Id" OrderDirection="Ascending">
							<Filters>
								<PropertyFilter	PropertyName="Id.WorkOrderSchedule"	Operator="="		PropertyValue="${WorkOrderSchedule}" />
								<InFilter PropertyName="Id.Job.Id">
									<Subquery Type="Job">
										<Filters>
											<PropertyFilter	PropertyName="ProgressStatus"	Operator="="		PropertyValue="${Job.ProgressStatus}" />
										</Filters>
										<Properties>
											<Property Name="Id" Alias="Job" Type="Property" />
										</Properties>
									</Subquery>
								</InFilter>
							</Filters>
						</GetList>

						<ForEach Name="For each WorkOrderScheduleJob" In="${WorkOrderScheduleJobs}" As="WorkOrderScheduleJob">
							<Command Name="CheckValidationRules" CommandName="DomainObject_GetValidationRulesSummary">
								<Parameter	Name="DomainObject"				Direction="In"		Value="${WorkOrderScheduleJob.Id.Job}" />
								<Parameter	Name="NewProgressStatus"		Direction="In"		Value="${SelectedProgressStatus}" />
								<Parameter	Name="ValidationRulesSummary"	Direction="Out"												OutputProperty="${ValidationRulesSummary}" />
							</Command>

							<Choose Name="Check if the validation rules are met for the new progress status">
								<When Name="When validation rules are met" Condition="${ValidationRulesSummary} == Empty">
									<Assign Name="Set selected ProgressStatus" Property="${WorkOrderScheduleJob.DesiredProgressStatus}" Value="${SelectedProgressStatus}" />

									<ChangeStatus Name="Set record status linked to ProgressStatus" DomainObject="${WorkOrderScheduleJob}" NewStatus="${SelectedProgressStatus.NextStatus}" />
								</When>

								<Otherwise>
									<Counter Name="Increment InvalidProgressStatusCount" Property="${InvalidProgressStatusCount}" Step="1" Comment="Count the number of invalid progrees status jobs" />

									<Assign Name="Assign the validation rule message (will be the same for all jobs because we assign the same progress status)" Property="${LastValidationRuleMessage}" Value="${ValidationRulesSummary}" />
								</Otherwise>
							</Choose>
						</ForEach>
					</When>


					<When Name="Otherwise, the transition is not valid or not authorized. Add progress status if not added already" Condition="${UnauthorizedTransitions} == Empty || #containselement(${UnauthorizedTransitions}, ${Job.ProgressStatus}, False) == False">
						<AddToList Name="Add job.ProgressStatus to UnauthorizedTransitions" List="${UnauthorizedTransitions}" Item="${Job.ProgressStatus}" />
					</When>
				</Choose>
			</ForEach>
		</Transaction>

		<Choose Name="Check if the there are authorization/validation errors">
			<When Name="When unauthorized progress status transitions found" Condition="${UnauthorizedTransitions} != Empty &amp;&amp; ${UnauthorizedTransitions.Count} &gt; 0">
				<Message Name="InvalidProgressStatusTransitionsFound" MessageCode="2256">
					<Parameter	Name="SelectedProgressStatus"	Direction="In"		Value="${SelectedProgressStatus}" />
					<Parameter	Name="UnauthorizedTransitions"	Direction="In"		Value="${UnauthorizedTransitions}" />
				</Message>
			</When>


			<When Name="When there are jobs with progress status validation rules that are not met" Condition="${InvalidProgressStatusCount} &gt; 0">
				<Message Name="InvalidProgressStatusTransitionsFound" MessageCode="3362">
					<Parameter	Name="Count"	Direction="In"		Value="${InvalidProgressStatusCount}" />
					<Parameter	Name="Reason"	Direction="In"		Value="${LastValidationRuleMessage}" />
				</Message>
			</When>
		</Choose>

		<UserContent Name="Post" />
	</Execution>
</Workflow>