ScopedSessionDomain : Client
L’API ScopedSessionDomain est un script include qui contient des méthodes côté client qui fournissent des fonctionnalités liées au domaine de session actuel.
Cette API est uniquement disponible si le module d’extension Domain Support - Domain Extensions Installer (com.glide.domain.msp_extensions) a été activé dans l’instance. En outre, l’appelant doit avoir le rôle admin pour accéder à cette API.
ScopedSessionDomain : getCurrentDomainID()
Renvoie les sys_id du domaine actuel pour la session de l’utilisateur connecté.
L’identificateur renvoyé dépend du type de domaine et de l’instanciation de ce domaine.
- Si l’utilisateur est configuré dans le domaine global et qu’il n’utilise pas le sélecteur de domaine pour changer de domaine, la méthode renvoie null.
- Si l’utilisateur utilise le sélecteur de domaine pour basculer vers le domaine global, la méthode renvoie la chaîne « global ».
- Pour tous les autres domaines, la méthode renvoie les sys_id de ce domaine.
Pour accéder à cette méthode à partir d’un script côté client, vous devez utiliser GlideAjax() pour l’invoquer. Pour invoquer cette méthode à partir d’un script côté serveur, utilisez quelque chose de similaire à ce qui suit pour instancier l’objet et accéder à la méthode.
var ssg = new global.ScopedSessionDomain();
domainID = ssg.getCurrentDomainID();| Nom | Type | Description |
|---|---|---|
| Aucun |
| Type | Description |
|---|---|
| Chaîne | Sys_id du domaine de session de l’utilisateur actuellement connecté. Il s’agit des mêmes informations qui apparaissent dans le sélecteur de domaine. |
Cet exemple montre comment appeler la méthode getCurrentDomainID() à partir d’un script côté client.
// This example is calling the script include in a client script.
// This particular record is within the "Service Portal - Standard Ticket" scope.
// To reproduce this example:
// 1. Change application scope to "Service Portal - Standard Ticket"
// 2. Navigate to Client Script table and open a new form and name it anything
// 3. Set table=ticket_configuration (this table is within the same scope)
// 4. Set UI type=Desktop and Type=onLoad
// 5. Populate the script field with the script above
// 6. Navigate to the ticket_configuration table and open any form.
//
// This will trigger the client script, invoke the API, and pop up a browser alert containing the sys_id of the user's current domain
function onLoad() {
var ga = new GlideAjax("global.ScopedSessionDomain"); // Set the script include
ga.addParam("sysparm_name", "getCurrentDomainID"); // Set the getCurrentDomainID method
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer); // Pops up the sys_id of the domain record
}
}