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

ActionField1251

Beschrijving: Select a JobPlan (ObjectJobPlan) and add it to the PmJob by creating a link (PmJobJobPlan) between the template (JobPlan) and the PmJob. Custom: Nee

Propertiesbewerken

Property Type Accessor
PmJob PmJob Root
EquipmentContext Context Optional
JobPlanContext Context Optional
SelectionListConfiguration UltimoString Optional

XMLbewerken

<Workflow Name="ActionField1251" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Select a JobPlan (ObjectJobPlan) and add it to the PmJob by creating a link (PmJobJobPlan) between the template (JobPlan) and the PmJob.</Description>
	<Properties>
		<Property	Name="PmJob"										Type="PmJob"							Accessor="Root"		Direction="In" />

		<Property	Name="EquipmentContext"								Type="Context"							Accessor="Optional"	Direction="In"		Default="EquipmentContext.Fleet"	Comment="Context used for messages" />
		<Property	Name="JobPlanContext"								Type="Context"							Accessor="Optional"	Direction="In"		Default="JobPlanContext.Fleet"		Comment="Only select JobPlans with this context" />
		<Property	Name="SelectionListConfiguration"					Type="UltimoString"						Accessor="Optional"	Direction="In"		Default="JobPlan"					Comment="JobPlans in grid are shown with this SelectionListConfiguration. Default is 'JobPlan'" />

		<Property	Name="AdditionalSqlWhereClause"						Type="UltimoString"						Accessor="Internal" />
		<Property	Name="IsFeatureToggleInspectionsNewStyleEnabled"	Type="Boolean"							Accessor="Internal" />
		<Property	Name="ObjectJobPlanList"							Type="List[ObjectJobPlan]"				Accessor="Internal" />
		<Property	Name="ObjectJobPlanQueryResult"						Type="QueryResult"						Accessor="Internal" />
		<Property	Name="PmJobExternals"								Type="List[PmJobExternal]"				Accessor="Internal" />
		<Property	Name="PmJobHasDetails"								Type="Boolean"							Accessor="Internal" />
		<Property	Name="PmJobInspectionLines"							Type="List[PmJobInspectionLine]"		Accessor="Internal" />
		<Property	Name="PmJobJobPlan"									Type="PmJobJobPlan"						Accessor="Internal" />
		<Property	Name="PmJobJobPlanCount"							Type="Int64"							Accessor="Internal"						Default="0" />
		<Property	Name="PmJobMaterials"								Type="List[PmJobMaterial]"				Accessor="Internal" />
		<Property	Name="PmJobPurchaseRequestLines"					Type="List[PmJobPurchaseRequestLine]"	Accessor="Internal" />
		<Property	Name="PmJobResources"								Type="List[PmJobResource]"				Accessor="Internal" />
		<Property	Name="PmJobTools"									Type="List[PmJobTool]"					Accessor="Internal" />
		<Property	Name="SelectedJobPlan"								Type="JobPlan"							Accessor="Internal" />
		<Property	Name="SelectedObjectJobPlan"						Type="ObjectJobPlan"					Accessor="Internal" />
		<Property	Name="SkillCategory"								Type="QueryResult"						Accessor="Internal" />
		<Property	Name="SqlWhereClause"								Type="UltimoString"						Accessor="Internal" />
		<Property	Name="ThrowValidation"								Type="Boolean"							Accessor="Internal"						Default="False" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

		<Validation Name="ValidatePmJobIsOpen" Condition="${PmJob.Status} == PmJobStatus.Created" MessageCode="2664">
			<Parameter	Name="JobPlanContext"	Direction="In"		Value="${JobPlanContext}" />
			<Parameter	Name="PmJob"			Direction="In"		Value="${PmJob}" />
		</Validation>

		<When Name="When context on PmJob is Fleet" Condition="${PmJob.Context} == PmJobContext.Fleet">
			<Validation Name="ValidatePmJobHasEquipmentToAddJobPlanFor" Condition="${PmJob.Equipment} != Empty" MessageCode="2660">
				<Parameter	Name="EquipmentContext"	Direction="In"		Value="${EquipmentContext}" />
				<Parameter	Name="PmJob"			Direction="In"		Value="${PmJob}" />
			</Validation>
		</When>

		<WorkflowCall Name="Check for PmJob details and ask to continue (to remove later on) if found" WorkflowName="PmJob_CheckForDetails">
			<Parameter	Name="JobPlanContext"	Direction="In"		Value="${JobPlanContext}" />
			<Parameter	Name="PmJob"			Direction="In"		Value="${PmJob}" />
			<Parameter	Name="HasDetails"		Direction="Out"									OutputProperty="${PmJobHasDetails}" />
		</WorkflowCall>

		<Transaction>
			<Query Name="Query the Id of the SkillCategory for this PmJob's JobPlan (if applicable)" Type="PmJobJobPlan" OutputProperty="${SkillCategory}">
				<Joins>
					<Join	Name="JobPlan"			Alias="jp"	Type="InnerJoin" />
					<Join	Name="jp.SkillCategory"	Alias="skc"	Type="InnerJoin" />
				</Joins>
				<Filters>
					<PropertyFilter	PropertyName="PmJob"		Operator="="		PropertyValue="${PmJob}" />
					<PropertyFilter	PropertyName="jp.Status"	Operator="&gt;="	PropertyValue="0"			Comment="Do not include trashed records" />
				</Filters>
				<Properties>
					<Property Name="skc.Id" Alias="id" Type="GroupProperty" />
				</Properties>
			</Query>
		</Transaction>

		<Choose Name="Check context on PmJob">
			<When Name="When context is Fleet" Condition="${PmJob.Context} == PmJobContext.Fleet">
				<Transaction>
					<WorkflowCall Name="ObjectJobPlan_GetListForEquipment" WorkflowName="ObjectJobPlan_GetListForEquipment">
						<Parameter	Name="Equipment"		Direction="In"		Value="${PmJob.Equipment}" />
						<Parameter	Name="EquipmentType"	Direction="In"		Value="${PmJob.Equipment.EquipmentType}" />
						<Parameter	Name="JobPlanContext"	Direction="In"		Value="${JobPlanContext}" />
						<Parameter	Name="SkillCategory"	Direction="In"		Value="${SkillCategory}" />
						<Parameter	Name="ObjectJobPlans"	Direction="Out"													OutputProperty="${ObjectJobPlanList}" />
					</WorkflowCall>

					<Validation Name="ValidateJobPlansFoundForEquipment" Condition="${ObjectJobPlanList} != Empty &amp;&amp; ${ObjectJobPlanList.Count} != 0" MessageCode="2661">
						<Parameter	Name="EquipmentContext"	Direction="In"		Value="${EquipmentContext}" />
					</Validation>

					<Assign Name="Build additional SQL WHERE clause" Property="${AdditionalSqlWhereClause}" Value=" AND ObjjpId IN (#foreach(${ObjectJobPlan} in ${ObjectJobPlanList})#each'${ObjectJobPlan.Id}'#between,#end)" />
					<Assign Name="Build SQL WHERE clause" Property="${SqlWhereClause}" Value="=#concat('ObjjpRecStatus &gt;= 0', ' ', ${AdditionalSqlWhereClause})" />
				</Transaction>

				<SystemDialog Name="DialogSelectObjectJobPlan" DialogName="SelectDomainObject">
					<Parameter	Name="EntityName"					Direction="In"		Value="ObjectJobPlan" />
					<Parameter	Name="SelectionListConfiguration"	Direction="In"		Value="Default" />
					<Parameter	Name="SqlWhereClause"				Direction="In"		Value="${SqlWhereClause}" />
					<Parameter	Name="DomainObject"					Direction="Out"									OutputProperty="${SelectedObjectJobPlan}" />
				</SystemDialog>

				<Assign Name="Set SelectedJobPlan" Property="${SelectedJobPlan}" Value="${SelectedObjectJobPlan.JobPlan}" />
			</When>

			<Otherwise Name="Otherwise, context other than Fleet">
				<Transaction>
					<Query Name="Query the Ids of all JobPlans suitable for this PmJob" Type="JobPlan" OrderBy="Id" OrderDirection="Ascending" OutputProperty="${ObjectJobPlanQueryResult}">
						<Joins>
							<Join	Name="SkillCategory"	Alias="skc"	Type="LeftOuterJoin" />
						</Joins>
						<Filters>
							<PropertyFilter	PropertyName="Context"	Operator="="		PropertyValue="${JobPlanContext}" />
							<PropertyFilter	PropertyName="Status"	Operator="&gt;="	PropertyValue="0"					Comment="Do not include trashed records" />
							<WhenFilter Condition="${SkillCategory.Count} != 0">
								<CombinedFilter FilterOperator="Or">
									<PropertyEmptyFilter PropertyName="SkillCategory" />
									<PropertyFilter	PropertyName="skc.Id"	Operator="="		PropertyValue="=#getpropertyvalue(#elementat(${SkillCategory}, 0), 'id')" />
								</CombinedFilter>
							</WhenFilter>
						</Filters>
						<Properties>
							<Property Name="Id" Alias="id" Type="GroupProperty" />
						</Properties>
					</Query>
				</Transaction>

				<Assign Name="Build SQL WHERE clause" Property="${SqlWhereClause}" Value="JpRecStatus &gt;= 0 AND JpContext = ${JobPlanContext}" />

				<When Name="When applicable JobPlans limited by SkillCategory found" Condition="${SkillCategory.Count} != 0 &amp;&amp; ${ObjectJobPlanQueryResult.Count} != 0" Comment="Only the SkillCategory can limit the applicable JobPlans">
					<Assign Name="Build additional SQL WHERE clause" Property="${AdditionalSqlWhereClause}" Value="AND JpId IN (#foreach(${ObjectJobPlan} in ${ObjectJobPlanQueryResult})#each'${ObjectJobPlan.id}'#between,#end)" />
					<Assign Name="Add addition to SQL WHERE clause" Property="${SqlWhereClause}" Value="=#concat(${SqlWhereClause}, ' ', ${AdditionalSqlWhereClause})" />
				</When>

				<SystemDialog Name="DialogSelectJobPlan" DialogName="SelectDomainObject">
					<Parameter	Name="EntityName"					Direction="In"		Value="JobPlan" />
					<Parameter	Name="SelectionListConfiguration"	Direction="In"		Value="${SelectionListConfiguration}" />
					<Parameter	Name="SqlWhereClause"				Direction="In"		Value="${SqlWhereClause}" />
					<Parameter	Name="DomainObject"					Direction="Out"												OutputProperty="${SelectedJobPlan}" />
				</SystemDialog>
			</Otherwise>
		</Choose>

		<Transaction>
			<GetCount Name="Get PmJobJobPlan Count" Type="PmJobJobPlan" OutputProperty="${PmJobJobPlanCount}">
				<Joins>
					<Join	Name="JobPlan"	Alias="outerJp"	Type="InnerJoin" />
				</Joins>
				<Filters>
					<PropertyFilter	PropertyName="PmJob"	Operator="="		PropertyValue="${PmJob}" />
					<PropertyFilter	PropertyName="JobPlan"	Operator="="		PropertyValue="${SelectedJobPlan}" />
					<InFilter PropertyName="outerJp.Id">
						<Subquery Type="JobPlanInspectionLine">
							<Joins>
								<Join	Name="Id.JobPlan"	Alias="innerJp"	Type="InnerJoin" />
							</Joins>
							<Filters>
								<PropertyFilter	PropertyName="Id.JobPlan"	Operator="="		PropertyValue="${SelectedJobPlan}" />
							</Filters>
							<Properties>
								<Property Name="innerJp.Id" Type="Property" />
							</Properties>
						</Subquery>
					</InFilter>
				</Filters>
			</GetCount>
		</Transaction>

		<When Name="Check for double JobPlans" Condition="${PmJobJobPlanCount} &gt;= 1">
			<Command Name="PmJob_IsFeatureToggleInspectionsNewStyleEnabled" CommandName="PmJob_IsFeatureToggleInspectionsNewStyleEnabled">
				<Parameter	Name="PmJob"					Direction="In"		Value="${PmJob}" />
				<Parameter	Name="FeatureToggleIsEnabled"	Direction="Out"							OutputProperty="${IsFeatureToggleInspectionsNewStyleEnabled}" />
			</Command>

			<When Name="IsFeatureToggleInspectionsNewStyleEnabled" Condition="${IsFeatureToggleInspectionsNewStyleEnabled} == True">
				<ContinuationQuestion Name="Add double JobPlan?" MessageCode="3702">
					<Parameter	Name="Job"		Direction="In"		Value="${PmJob}" />
					<Parameter	Name="JobPlan"	Direction="In"		Value="${SelectedJobPlan}" />
				</ContinuationQuestion>
			</When>
		</When>

		<WorkflowCall Name="JobPlan_ValidateMultiCompanyJobPlanMaterial" WorkflowName="JobPlan_ValidateMultiCompanyJobPlanMaterial">
			<Parameter	Name="JobPlan"			Direction="In"		Value="${SelectedJobPlan}" />
			<Parameter	Name="ThrowValidation"	Direction="Out"									OutputProperty="${ThrowValidation}" />
		</WorkflowCall>

		<Validation Name="JobPlan contains materials and multiple companies" Condition="${ThrowValidation} == False" MessageCode="3662">
			<Parameter	Name="JobPlan"	Direction="In"		Value="${SelectedJobPlan}" />
		</Validation>

		<Transaction>
			<When Name="When PmJob has details to delete" Condition="${PmJobHasDetails}">
				<WorkflowCall Name="PmJob_DeleteDetails" WorkflowName="PmJob_DeleteDetails">
					<Parameter	Name="PmJob"	Direction="In"		Value="${PmJob}" />
				</WorkflowCall>
			</When>

			<WorkflowCall Name="Create a link (PmJobJobPlan) between the selected template (JobPlan) and the PmJob" WorkflowName="PmJobJobPlan_CreatePmJobJobPlanForJobPlanAndPmJob">
				<Parameter	Name="JobPlan"		Direction="In"		Value="${SelectedJobPlan}" />
				<Parameter	Name="PmJob"		Direction="In"		Value="${PmJob}" />
				<Parameter	Name="PmJobJobPlan"	Direction="Out"									OutputProperty="${PmJobJobPlan}" />
			</WorkflowCall>
		</Transaction>

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