my ($status,$msg,$failure); my %ALMActivityFieldMap = ( # Activity field => Task Field "Task" => "id", "Headline" => "Headline", "Securitypolicy"=> "Securitypolicy", "Description" => "Description", "Project" => "Project", ); # Do not proceed if the current ALMTask has no project my $currProject = $entity->GetFieldValue("Project")->GetValue(); if ($currProject eq ""){ return; } # Do not proceed if the current action is ALMTask submit my $actionName=""; eval {$actionName = $entity->GetActionName();}; $session->OutputDebugString("\nAction Name is: $actionName\n"); if ($actionName eq "Open"){ return; } # Query ALMWorkCOnfigurations to determine which child types need to be built my @value = ("Yes","YES"); my $currTypeLabel = $entity->GetFieldValue("Type")->GetValue(); my $currEntityDef = $entity->GetEntityDefName(); $session->OutputDebugString("Getting $currEntityDef Children TypeLabels for: $currProject"); my $createChildTypes = "ChildrenTypes_primary"; if ($entity->GetFieldValue("Activities")->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,[ALMActivity]); $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 ALMActivity of its Type my $currChildTypeLabel = $resultset->GetColumnValue(1); next if (($currChildTypeLabel eq "" ) or ($currChildTypeLabel =~ /^\s+$/)); # Set the field values from the MAP based on values on its parent ALMTask my $ALMActivityObj = $session->BuildEntity("ALMActivity"); foreach my $actvFieldName ( keys %ALMActivityFieldMap ) { my $taskFieldName = $ALMActivityFieldMap{$actvFieldName}; my $taskFieldValue = $entity->GetFieldValue("$taskFieldName")->GetValue(); $session->OutputDebugString("# Setting $actvFieldName to $taskFieldValue"); $failure = $ALMActivityObj->SetFieldValue("$actvFieldName","$taskFieldValue"); } my %attrib = ( Type => $currChildTypeLabel, ); if ($createChildTypes eq "ChildrenTypes_primary"){ $attrib{"PrimaryActivity"}=1; } elsif ($createChildTypes eq "ChildrenTypes_secondary"){ $attrib{"SecondaryActivity"}=1; } my $retVal = SetEntityFieldVals($ALMActivityObj,1,%attrib); }