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

ActionField1266

Beschrijving: Change status of all JobJobPlans (products) linked to Job to Canceled . Custom: Nee

Propertiesbewerken

Property Type Accessor
Job Job Root
ContactPersonContext Context Optional
SkipQuestionJobScheduleParts Boolean Optional

XMLbewerken

<Workflow Name="ActionField1266" Version="2025.07.28" WorkflowType="Standard" xmlns="urn:Ultimo.Framework.Workflow-mapping">
	<Security EditLevel="10" ViewLevel="20" UserContentLevel="30" />
	<Description>Change status of all JobJobPlans (products) linked to Job to Canceled .</Description>
	<Properties>
		<Property	Name="Job"								Type="Job"						Accessor="Root"		Direction="In" />

		<Property	Name="ContactPersonContext"				Type="Context"					Accessor="Optional"	Direction="In"		Default="EmployeeContext.ContactPerson"		Comment="Context used for label in dialog" />
		<Property	Name="SkipQuestionJobScheduleParts"		Type="Boolean"					Accessor="Optional"	Direction="In"		Default="False"								Comment="Set to True to skip question and automatically remove JobScheduleParts" />

		<Property	Name="ApprovedJobJobPlanCount"			Type="Int64"					Accessor="Internal" />
		<Property	Name="ApproveOpenProducts"				Type="RequestResult"			Accessor="Internal"						Default="No" />
		<Property	Name="CanceledCustomerContactPerson"	Type="ObjectContact"			Accessor="Internal" />
		<Property	Name="CanceledCustomerDate"				Type="DateTime"					Accessor="Internal"						Default="#{Environment.CurrentDateTime}" />
		<Property	Name="CanceledCustomerRemarks"			Type="UltimoString"				Accessor="Internal" />
		<Property	Name="ContactPersons"					Type="List[ObjectContact]"		Accessor="Internal" />
		<Property	Name="FinishedInspectionLines"			Type="List[JobInspectionLine]"	Accessor="Internal" />
		<Property	Name="JobJobPlansToCancel"				Type="List[JobJobPlan]"			Accessor="Internal" />
		<Property	Name="JobJobPlansToDelete"				Type="List[JobJobPlan]"			Accessor="Internal" />
		<Property	Name="JobSchedulePartCount"				Type="Int64"					Accessor="Internal" />
		<Property	Name="RequestLineInOrderProcessCount"	Type="Int64"					Accessor="Internal" />
		<Property	Name="RequestLineInTenderProcessCount"	Type="Int64"					Accessor="Internal" />
	</Properties>
	<Settings>
		<SettingsGroup Name="JobResource">
			<Setting	Name="RemoveJobScheduleParts"	Type="Boolean" />
		</SettingsGroup>
	</Settings>
	<Execution>
		<UserContent Name="Pre" />

		<Validation Name="JobPlan from Pm Check" Condition="${Job.PmJob} == Empty" MessageCode="3713">
			<Parameter	Name="Job"		Direction="In"		Value="${Job}" />
			<Parameter	Name="PmJob"	Direction="In"		Value="${Job.PmJob}" />
		</Validation>

		<WorkflowCall Name="Check linked reported faults" WorkflowName="JobInspectionLine_ValidateLinkedReportedFaults">
			<Parameter	Name="Action"	Direction="In"		Value="CancelJobJobPlans" />
			<Parameter	Name="Job"		Direction="In"		Value="${Job}" />
		</WorkflowCall>

		<Transaction>
			<GetCount Name="Count approved products linked to job" Type="JobJobPlan" OutputProperty="${ApprovedJobJobPlanCount}">
				<Filters>
					<PropertyFilter	PropertyName="Job"		Operator="="		PropertyValue="${Job}" />
					<PropertyFilter	PropertyName="Status"	Operator="="		PropertyValue="JobJobPlanStatus.Approved" />
				</Filters>
			</GetCount>

			<GetCount Name="Count scheduled parts for JobResources" Type="JobSchedulePart" OutputProperty="${JobSchedulePartCount}">
				<Joins>
					<Join	Name="JobResource"		Alias="jobr"	Type="InnerJoin" />
					<Join	Name="jobr.JobJobPlan"	Alias="jobjpl"	Type="InnerJoin" />
				</Joins>
				<Filters>
					<PropertyFilter	PropertyName="jobjpl.Job"		Operator="="		PropertyValue="${Job}" />
					<PropertyFilter	PropertyName="jobjpl.Status"	Operator="!="		PropertyValue="JobJobPlanStatus.Canceled" />
				</Filters>
			</GetCount>

			<GetCount Name="Count purchase request lines in order process" Type="PurchaseRequestLine" OutputProperty="${RequestLineInOrderProcessCount}">
				<Joins>
					<Join	Name="JobJobPlan"	Alias="jobjpl"	Type="InnerJoin" />
				</Joins>
				<Filters>
					<PropertyFilter	PropertyName="jobjpl.Job"	Operator="="		PropertyValue="${Job}" />
					<InFilter PropertyName="Status" Values="PurchaseRequestLineStatus.PurchaseCreated, PurchaseRequestLineStatus.PartiallyDelivered, PurchaseRequestLineStatus.Delivered, PurchaseRequestLineStatus.Closed" />
				</Filters>
			</GetCount>

			<GetCount Name="Count purchase request lines in tender process" Type="PurchaseRequestLine" OutputProperty="${RequestLineInTenderProcessCount}">
				<Joins>
					<Join	Name="JobJobPlan"	Alias="jobjpl"	Type="InnerJoin" />
				</Joins>
				<Filters>
					<PropertyFilter	PropertyName="jobjpl.Job"	Operator="="		PropertyValue="${Job}" />
					<PropertyFilter	PropertyName="Status"		Operator="="		PropertyValue="PurchaseRequestLineStatus.Tender" />
				</Filters>
			</GetCount>
		</Transaction>

		<When Name="When purchase request lines found in order/tender process" Condition="${RequestLineInOrderProcessCount} != 0 || ${RequestLineInTenderProcessCount} != 0">
			<ContinuationQuestion Name="ContinueDespiteRequestLinesInOrderOrTenderProcess" MessageCode="2685">
				<Parameter	Name="OrderProcess"		Direction="In"		Value="=${RequestLineInOrderProcessCount} != 0" />
				<Parameter	Name="Single"			Direction="In"		Value="False" />
				<Parameter	Name="TenderProcess"	Direction="In"		Value="=${RequestLineInTenderProcessCount} != 0" />
			</ContinuationQuestion>
		</When>

		<When Name="When scheduled parts found" Condition="${JobSchedulePartCount} != 0 &amp;&amp; ${SkipQuestionJobScheduleParts} == False">
			<ContinuationQuestion Name="ContinueAndRemoveScheduledPartsFromPlanning" MessageCode="2684" Default="Yes">
				<Parameter	Name="Single"	Direction="In"		Value="False" />
			</ContinuationQuestion>
		</When>

		<Transaction>
			<Assign Name="Set setting for status transition logic" Property="#{Settings.JobResource.RemoveJobScheduleParts}" Value="True" />

			<GetList Name="Get open products linked to job" Type="JobJobPlan" OutputProperty="${JobJobPlansToDelete}" OrderBy="Id" OrderDirection="Ascending">
				<Filters>
					<PropertyFilter	PropertyName="Job"		Operator="="		PropertyValue="${Job}" />
					<PropertyFilter	PropertyName="Status"	Operator="="		PropertyValue="JobJobPlanStatus.Created" />
				</Filters>
			</GetList>

			<GetList Name="Get quoted/approved products linked to job" Type="JobJobPlan" OutputProperty="${JobJobPlansToCancel}" OrderBy="Id" OrderDirection="Ascending">
				<Filters>
					<PropertyFilter	PropertyName="Job"	Operator="="		PropertyValue="${Job}" />
					<InFilter PropertyName="Status" Values="JobJobPlanStatus.Quotation, JobJobPlanStatus.Approved" />
				</Filters>
			</GetList>

			<Choose Name="Check if a contact person is set on job">
				<When Name="When contact person is set" Condition="${Job.CustomerContactPerson} != Empty">
					<GetItem Name="Get" Type="ObjectContact" OutputProperty="${CanceledCustomerContactPerson}">
						<Filters>
							<PropertyFilter	PropertyName="Customer"	Operator="="		PropertyValue="${Job.Customer}" />
							<PropertyFilter	PropertyName="Employee"	Operator="="		PropertyValue="${Job.CustomerContactPerson}" />
						</Filters>
					</GetItem>
				</When>

				<Otherwise Name="Otherwise, no contact person is set">
					<GetList Name="Get contact persons for this job's customer, if any" Type="ObjectContact" OutputProperty="${ContactPersons}" OrderBy="Id" OrderDirection="Ascending">
						<Filters>
							<PropertyFilter	PropertyName="Customer"	Operator="="		PropertyValue="${Job.Customer}" />
							<NotFilter>
								<PropertyEmptyFilter PropertyName="Employee" />
							</NotFilter>
						</Filters>
					</GetList>

					<When Name="When there's only one contact person found" Condition="${ContactPersons.Count} == 1">
						<Assign Name="Prefill for dialog" Property="${CanceledCustomerContactPerson}" Value="${ContactPersons[0]}" />
					</When>
				</Otherwise>
			</Choose>
		</Transaction>

		<When Name="When products to cancel or delete are found" Condition="${JobJobPlansToCancel.Count} != 0 || ${JobJobPlansToDelete.Count} != 0">
			<ContinuationQuestion Name="ContinueDespiteOpenDetailLines" MessageCode="3726">
				<Parameter	Name="Action"	Direction="In"		Value="CancelOrDelete" />
			</ContinuationQuestion>
		</When>

		<When Name="When products to cancel are found" Condition="${JobJobPlansToCancel.Count} != 0">
			<WorkflowCall Name="Get cancellation details" WorkflowName="Dialog_JobJobPlan_GetCancellationDetails">
				<Parameter	Name="ContactPersonContext"				Direction="In"		Value="${ContactPersonContext}" />
				<Parameter	Name="Customer"							Direction="In"		Value="${Job.Customer}" />
				<Parameter	Name="DomainObject"						Direction="In"		Value="${JobJobPlansToCancel[0]}" />
				<Parameter	Name="IsPlural"							Direction="In"		Value="False" />
				<Parameter	Name="CanceledCustomerContactPerson"	Direction="InOut"	Value="${CanceledCustomerContactPerson}"	OutputProperty="${CanceledCustomerContactPerson}" />
				<Parameter	Name="CanceledCustomerDate"				Direction="InOut"	Value="${CanceledCustomerDate}"				OutputProperty="${CanceledCustomerDate}" />
				<Parameter	Name="CanceledCustomerRemarks"			Direction="Out"													OutputProperty="${CanceledCustomerRemarks}" />
			</WorkflowCall>
		</When>

		<Transaction>
			<Assign Name="Allow deletion in JobInspectionLine_PreTrash because JobPlan is about to be cancelled" Property="#{Settings.JobJobPlan.Cancelling}" Value="True" />

			<GetList Name="Inspectionlines that should be kept" Type="JobInspectionLine" OutputProperty="${FinishedInspectionLines}" OrderBy="Id" OrderDirection="Ascending">
				<Filters>
					<PropertyFilter	PropertyName="Id.Job"	Operator="="		PropertyValue="${Job}" />
					<InFilter PropertyName="Status" Values="JobInspectionLineStatus.Skipped, JobInspectionLineStatus.Completed, JobInspectionLineStatus.Finished" />
				</Filters>
			</GetList>

			<ForEach Name="Remove JobJobPlan connection" In="${FinishedInspectionLines}" As="InspectionLine">
				<Assign Name="JobJobPlan connection" Property="${InspectionLine.JobJobPlan}" Value="Empty" />
			</ForEach>

			<ForEach Name="Loop products to delete" In="${JobJobPlansToDelete}" As="JobJobPlan">
				<DeleteObject Name="Delete open JobJobPlan" DomainObject="${JobJobPlan}" />
			</ForEach>

			<ForEach Name="Loop products to cancel" In="${JobJobPlansToCancel}" As="JobJobPlan">
				<ChangeStatus Name="Cancel quoted/approved product" DomainObject="${JobJobPlan}" NewStatus="JobJobPlanStatus.Canceled" />

				<Assign Name="Set cancellation customer contant person" Property="${JobJobPlan.CanceledCustomerContactPerson}" Value="${CanceledCustomerContactPerson.Employee?}" />
				<Assign Name="Set cancellation customer date" Property="${JobJobPlan.CanceledDateCustomerContactPerson}" Value="${CanceledCustomerDate}" />

				<When Name="When remarks are not empty" Condition="#htmltoplain(${CanceledCustomerRemarks}) != Empty">
					<Command Name="Append text to internal remarks" CommandName="DomainObject_AppendComment">
						<Parameter	Name="AddTextAboveTotalText"	Direction="In"		Value="#{Settings.Job.AddTextAboveTotalText}" />
						<Parameter	Name="DomainObject"				Direction="In"		Value="${JobJobPlan}" />
						<Parameter	Name="Property"					Direction="In"		Value="RemarkText" />
						<Parameter	Name="ShowEmployee"				Direction="In"		Value="True" />
						<Parameter	Name="TextToAppend"				Direction="In"		Value="${CanceledCustomerRemarks}" />
					</Command>
				</When>
			</ForEach>
		</Transaction>

		<When Name="When approved products found" Condition="${ApprovedJobJobPlanCount} != 0">
			<Message Name="JobTextsMightContainInfoThatWillNoLongerBeApplicable" MessageCode="2680">
				<Parameter	Name="CanceledProductsCount"	Direction="In"		Value="${ApprovedJobJobPlanCount}" />
			</Message>
		</When>

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