# Build ALMTask record(s) using ALMWorkConfigurations # Get default values from parent ALMRequest record my $id= $entity->GetFieldValue("id")->GetValue(); my $headline= $entity->GetFieldValue("Headline")->GetValue(); my $description= $entity->GetFieldValue("Description")->GetValue(); my $securitypolicy= $entity->GetFieldValue("SecurityPolicy")->GetValue(); my $priority= $entity->GetFieldValue("Severity")->GetValue(); my $currTypeLabel = $entity->GetFieldValue("Type")->GetValue(); $session->OutputDebugString("Script(CreateTask: found Request values.\n"); # Do not proceed if the current ALMRequest has no project my $currProject = $entity->GetFieldValue("Project")->GetValue(); if ($currProject eq ""){ return; } # Query ALMWorkCOnfigurations to determine which child types need to be built my @value = ("Yes", "YES"); my $currEntityDef = $entity->GetEntityDefName(); $session->OutputDebugString("Getting $currEntityDef Children TypeLabels for: $currProject"); my $createChildTypes = "ChildrenTypes_primary"; if ($entity->GetFieldValue("Tasks")->GetValueStatus() == $CQPerlExt::CQ_HAS_VALUE) { $createChildTypes = "ChildrenTypes_secondary"; } my $querydef = $session->BuildQuery("ALMWorkConfiguration"); $querydef->BuildField("$createChildTypes"); my $operator = $querydef->BuildFilterOperator($CQPerlExt::CQ_BOOL_OP_AND); $operator->BuildFilter("ALMProject", $CQPerlExt::CQ_COMP_OP_EQ,[$currProject]); $operator->BuildFilter("ALMRecordType", $CQPerlExt::CQ_COMP_OP_EQ,[$currEntityDef]); $operator->BuildFilter("ALMTypeLabel", $CQPerlExt::CQ_COMP_OP_EQ,[$currTypeLabel]); $operator->BuildFilter("$createChildTypes.Types.WorkConfiguration.ALMProject", $CQPerlExt::CQ_COMP_OP_EQ,[$currProject]); $operator->BuildFilter("$createChildTypes.Types.WorkConfiguration.ALMRecordType", $CQPerlExt::CQ_COMP_OP_EQ,[ALMTask]); $operator->BuildFilter("$createChildTypes.Types.WorkConfiguration.Obsolete", $CQPerlExt::CQ_COMP_OP_NEQ,\@value); my $resultset = $session->BuildResultSet($querydef); $resultset->Execute; while ($resultset->MoveNext eq $CQPerlExt::CQ_SUCCESS) { # For each TypeLabel returned, build an ALMTask of its Type my $currChildTypeLabel = $resultset->GetColumnValue(1); next if (($currChildTypeLabel eq "" ) or ($currChildTypeLabel =~ /^\s+$/)); my $ALMTaskObj = $session->BuildEntity("ALMTask"); my $failure = $ALMTaskObj->SetFieldRequirednessForCurrentAction("Priority",$CQPerlExt::CQ_OPTIONAL); my %attrib = ( Request => $id, Project => $currProject, Headline => $headline, Description => $description, SecurityPolicy => $securitypolicy, Type => $currChildTypeLabel, ); if ($createChildTypes eq "ChildrenTypes_primary"){ $attrib{"PrimaryTask"}=1; } elsif ($createChildTypes eq "ChildrenTypes_secondary"){ $attrib{"SecondaryTask"}=1; } my $retVal = SetEntityFieldVals($ALMTaskObj,1,%attrib); }