Opening a URL

The GSU_CQXE_OpenURL global hook opens a web browser window to a specified URL. The function first opens a confirmation dialog, whose message you can customize. If the user clicks OK in the dialog, the browser opens; if the user clicks Cancel, the dialog closes and focus returns to the record form.

This functionality is available on the ClearQuest Client and ClearQuest Web client. If a user attempts to open a URL from an older client, or from the ClearQuest client for Windows, the API returns an informational message. Pour afficher ce message pour l'utilisateur, appelez la fonction die.

To use the GSU_CQXE_OpenURL global hook function to open a URL, you must apply the GlobalScriptUtility (GSU_CQXE) package to update your schema with the global hook code.
  1. Dans ClearQuest Designer, cliquez avec le bouton droit de la souris sur la version du schéma dans laquelle vous souhaitez appliquer le package, puis sélectionnez Packages > Application du package. The Package Wizard opens.
  2. Développez le noeud GlobalScriptUtility dans la liste des packages et sélectionnez la version 1.0. Cliquez sur Next.
  3. Sélectionnez les types d'enregistrement où vous souhaitez appliquer le package. Cliquez sur Finish.
Le package GlobalScriptUtility est à présent appliqué au schéma que vous avez sélectionné. Pour vérifier l'installation du package, recherchez le nouveau script global GSU_CQXE dans le schéma.

Pour plus d'informations sur l'application de packages, voir Applying packages.

Exemples

The following examples show a record script that you can use with the global hooks to open a URL. In these examples, clicking an OpenIBM button opens a dialog and asks whether the user wants to open a browser to the specified URL. If the user clicks OK, a browser window opens to www.ibm.com; if the user clicks Cancel, the dialog closes.

Pour utiliser cet exemple, apportez les changements suivants à votre schéma:
  1. Create a record script named Open_Url, using the Perl or VBScript example.
  2. Add a new tab named OpenURL to the Defect_Base form in the Defect record type.
  3. On the OpenURL tab, add a new Button control named OpenIBM, and associate it with the Open_Url record script.

Exemple de langage Perl

sub Defect_Open_Url {
    my($result);
    my($param) = @_;
    # le nom du type d'enregistrement est Défaut
    
    $url="http://www.ibm.com";
    $msg="Do you want to open a browser to this URL?";
    my $session = $entity->GetSession(); 
    GSU_CQXE_OpenURL($session,$url,$msg);
    return $result;
}

Exemple de langage VBScript

Function Defect_Open_Url(param)
  ' param As Variant
  ' le nom tu type d'enregistrement est Defect
    REM add your hook code here
	Dim url
	Dim message
	set session = GetSession
	url = "http://www.ibm.com"
	message = "Do you want to open a browser to this URL?"
	Defect_Open_Url=GSU_CQXE_OpenURL(session,url,message)
End Function

Commentaires en retour