• 1 reply
  • Latest Post - ‏2014-01-05T23:58:49Z by DonaldN
94 Posts

Pinned topic DTDeployment record has no Approval record

‏2013-12-23T19:53:56Z |

Below is the code I use to create a DTDeployment record. If I run this from DOS command line, the newly created DTDeployment record has the first Approval record created inside.

When I run this code inside the BTBuild commit action hook (create a DTDeployment record from a good BTBuild), the Approval field is empty, why?


use CQPerlExt;
#### Start a CQ session
my $session = CQPerlExt::CQSession_Build();
eval {
          $session->UserLogon("admin", "", "USR02", "7.1.1");
          $userLogin = $session->GetUserLoginName() ;
          print  "Login name: $userLogin\n";
}; if ($@) { print  "Login failed:$@";}
# Create a new DTDeployment record
eval {
    $entity = $session->BuildEntity("DTDeployment");      
      $error = $entity->SetFieldValue("Owner", "admin");
      $error = $entity->SetFieldValue("ReleaseName", "R1");
      $error = $entity->SetFieldValue("BTBuild", "USR0200002877");
$error = $entity->SetFieldValue("Headline", "Deploy to ...");
        $error = $entity->SetFieldValue("Deployment_Unit_Reference", "DeployUnitLocation from BTBuild");
}; if ($@) { print  "SetFieldValue failed:$@";}
eval {
$returnval = $entity->Validate();
if ($returnval ne ""){
          print ("####### Validate failed: $returnval\n");
    } else {
          $id = $entity->GetFieldStringValue("Id");
     print ("####### $id" . " created.\n");
}; if ($@) { print  "Commit failed:$@";}
# All done.
  • DonaldN
    287 Posts

    Re: DTDeployment record has no Approval record


    It will be a miracle if anyone rather than you knows the answer, since you left out some crucial information.

    The code that you showed above does not set field value for "Approval", so it must be done in a hook of DTDeployment. What is the content of this hook and when will it be triggered?

    Also, you hard-coded everything in the above code for testing purpose, but in your actual hook code, some values must be dynamic and you need to make sure these values are valid when the hook is executed.