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

ActionField1265

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

Propertiesbewerken

Property Type Accessor
Job Job Root
ContactPersonContext Context Optional

XMLbewerken

<Workflow Name="ActionField1265" 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 Approved.</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="ApprovedCustomerContactPerson"	Type="ObjectContact"		Accessor="Internal" />
		<Property	Name="ApprovedCustomerDate"				Type="DateTime"				Accessor="Internal"						Default="#{Environment.CurrentDateTime}" />
		<Property	Name="ApprovedCustomerRemarks"			Type="UltimoString"			Accessor="Internal" />
		<Property	Name="ApproveOpenProducts"				Type="RequestResult"		Accessor="Internal"						Default="No" />
		<Property	Name="ContactPersons"					Type="List[ObjectContact]"	Accessor="Internal" />
		<Property	Name="JobJobPlans"						Type="List[JobJobPlan]"		Accessor="Internal" />
		<Property	Name="OpenJobJobPlanCount"				Type="Int64"				Accessor="Internal" />
	</Properties>
	<Execution>
		<UserContent Name="Pre" />

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

			<GetList Name="Get open/quoted products linked to job" Type="JobJobPlan" OutputProperty="${JobJobPlans}" OrderBy="Id" OrderDirection="Ascending">
				<Filters>
					<PropertyFilter	PropertyName="Job"	Operator="="		PropertyValue="${Job}" />
					<InFilter PropertyName="Status" Values="JobJobPlanStatus.Created, JobJobPlanStatus.Quotation" />
				</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="${ApprovedCustomerContactPerson}">
						<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="${ApprovedCustomerContactPerson}" Value="${ContactPersons[0]}" />
					</When>
				</Otherwise>
			</Choose>
		</Transaction>

		<Validation Name="ValidateProductsToApproveFound" Condition="${JobJobPlans.Count} != 0" MessageCode="2678" />

		<When Name="When open products found" Condition="${OpenJobJobPlanCount} != 0">
			<Question Name="AskIfOpenProductsShouldBeApprovedAsWell" Type="YesNoCancel" MessageCode="2679" Default="Yes" OutputProperty="${ApproveOpenProducts}">
				<Parameter	Name="Additional"			Direction="In"		Value="=${OpenJobJobPlanCount} != ${JobJobPlans.Count}"	Comment="If these are not the same, the open products are in addition to the quoted ones" />
				<Parameter	Name="OpenProductsCount"	Direction="In"		Value="${OpenJobJobPlanCount}" />
			</Question>
		</When>

		<WorkflowCall Name="Get approval details" WorkflowName="Dialog_JobJobPlan_GetApprovalDetails">
			<Parameter	Name="ContactPersonContext"				Direction="In"		Value="${ContactPersonContext}" />
			<Parameter	Name="Customer"							Direction="In"		Value="${Job.Customer}" />
			<Parameter	Name="DomainObject"						Direction="In"		Value="${JobJobPlans[0]}" />
			<Parameter	Name="IsPlural"							Direction="In"		Value="True" />
			<Parameter	Name="ApprovedCustomerContactPerson"	Direction="InOut"	Value="${ApprovedCustomerContactPerson}"	OutputProperty="${ApprovedCustomerContactPerson}" />
			<Parameter	Name="ApprovedCustomerDate"				Direction="InOut"	Value="${ApprovedCustomerDate}"				OutputProperty="${ApprovedCustomerDate}" />
			<Parameter	Name="ApprovedCustomerRemarks"			Direction="Out"													OutputProperty="${ApprovedCustomerRemarks}" />
		</WorkflowCall>

		<Transaction>
			<ForEach Name="Loop products to approve" In="${JobJobPlans}" As="JobJobPlan" Condition="${JobJobPlan.Status} == JobJobPlanStatus.Quotation || ${ApproveOpenProducts} == Yes">
				<ChangeStatus Name="Approve product" DomainObject="${JobJobPlan}" NewStatus="JobJobPlanStatus.Approved" />

				<Assign Name="Set approval customer contant person" Property="${JobJobPlan.ApprovedCustomerContactPerson}" Value="${ApprovedCustomerContactPerson.Employee?}" />
				<Assign Name="Set approval customer date" Property="${JobJobPlan.ApprovedDateCustomerContactPerson}" Value="${ApprovedCustomerDate}" />

				<When Name="When remarks are not empty" Condition="#htmltoplain(${ApprovedCustomerRemarks}) != 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="${ApprovedCustomerRemarks}" />
					</Command>
				</When>
			</ForEach>
		</Transaction>

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