Can Perl monitor for pop-up and automatically select Yes?

57 Views Asked by At

I have the below code embedded in a script where I can inserting records into a database through the business logic layer. When I ran the script a Win32 dialog box popped up and asked me a question in which I responded yes. This dialog box is only presented to the user if certain values are entered into the database. So it's a problem only a percentage of the time. Is there a command to embed in my script which ignores pop-ups with a default Yes response? Or is there a way to have the script respond and continue processing? I'm not seeing much on this topic when googling and searching this site. Perhaps there is and I'm searching the wrong phrase. If this is not possible I can have the business logic programmers put an exception for the role my script will run under.

#Process each action required to update the State field
            foreach $action (@performAction) {
                $entity->EditEntity($action);
                #Evaluate for validation errors
                $trappedErrorValidate = $entity->Validate();
                    if ($trappedErrorValidate ne "") {
                    print ERRFILE "The State field has not been updated from $startState to $finishState for record number @fieldValues[0] due to the error code below.\n";
                    print ERRFILE "Error Code:$trappedErrorValidate\n";
                    print ERRFILE "*********************************************************************************\n";
                        $entity->Revert();
                                  } else {
                                                #Commit and evaluate for errors
                                    $trappedErrorCommit =$entity->Commit();
                                    if ($trappedErrorCommit ne "") {
                                        print ERRFILE "The State field has not been updated from $startState to $finishState for record number @fieldValues[0] due to the error code below.\n";
                                        print ERRFILE "Error Code:$trappedErrorCommit\n";
                                        print ERRFILE "*********************************************************************************\n";
                                                                                           }else {
                                                          $stateChanges++; 
                                                                                                             } 
                                     }
                             }
1

There are 1 best solutions below

0
AdamSkwersky On

Do you have code in your ClearQuest hooks to pop up the dialog? These are not coming from the script you pasted, so they must be coming from the hooks.

What you could do is set a session variable in your script, e.g.

$session->SetNameValue("RUNNING_IN_SCRIPT", "true");

Then in your hook code have this:

my $runningInHook = $session->GetNameValue("RUNNING_IN_SCRIPT");
my $suppressPopup = $runningInHook eq "true";

Then anywhere you might do the popup, check if $suppressPopup, and assume "yes" instead of trying to pop up a dialog.