Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Automatically translated by Lango

Queries

...

Abfragen

Wenn Sie Abfragen in Axxerion in scripting, or when debugging performance issues, be aware of the following aspects that negatively effect performance.

Client specific fields

Do not use JUST client specific fields in queries if you can. For doing this, Workplace will have to always combine two data tables, which will require the system to always search a larger table (the one with client specific fields) than the core objects. Always try to add a Workplace core field (most commonly Skripten durchführen oder wenn Sie Performance-Probleme debuggen, sollten Sie sich der folgenden Aspekte bewusst sein, die die Performance negativ beeinflussen.

Kundenspezifische Felder

Verwenden Sie nach Möglichkeit nicht NUR mandantenspezifische Felder in Abfragen. Dazu muss Workplace immer zwei Datentabellen kombinieren, was dazu führt, dass das System immer eine größere Tabelle (die mit den mandantenspezifischen Feldern) durchsucht als die Kernobjekte. Versuchen Sie immer, ein Workplace-Kernfeld hinzuzufügen (am häufigsten createTime, updateTime, externalReference, closeTime, categoryFolderId).

If you do need to use client specific fields, try to limit them. The more fields you add, the more data that will need to be integrated, which in turn might take more time to run. So if you have a slow query, check if removing client specific fields has a positive effect (or vice versa, adding them has an adverse effect).

Empty query parameters

When using variables in a query, make sure they have values added to them. See the below scriptWenn Sie kundenspezifische Felder verwenden müssen, versuchen Sie, diese zu begrenzen. Je mehr Felder Sie hinzufügen, desto mehr Daten müssen integriert werden, was wiederum mehr Zeit für die Ausführung in Anspruch nehmen kann. Wenn Sie also eine langsame Abfrage haben, prüfen Sie, ob sich das Entfernen von kundenspezifischen Feldern positiv auswirkt (oder umgekehrt, ob das Hinzufügen von Feldern negative Auswirkungen hat).

Leere Abfrageparameter

Wenn Sie Variablen in einer Abfrage verwenden, stellen Sie sicher, dass ihnen Werte hinzugefügt wurden. Siehe das folgende Skript.

Code Block
contact = this;
manager = contact.managerContactId;
colleagues = find Contact by managerContactId == manager;

What you expect the script to do is to get the manager from the current contact. Then you use that manager to find all the other contacts assigned to that manager. There is a catch though: if this script runs on a contact that does not have a manager, the script will then search for ALL contacts. A better solution is to do the followingSie erwarten, dass das Script den Manager des aktuellen Kontakts ermittelt. Dann wird dieser Manager verwendet, um alle anderen Kontakte zu finden, die diesem Manager zugeordnet sind. Die Sache hat allerdings einen Haken: Wenn dieses Script auf einem Kontakt läuft, der keinen Manager hat, sucht das Script nach ALLEN Kontakten. Eine bessere Lösung ist, wie folgt vorzugehen.

Code Block
languagenone
contact = this;
manager = contact.managerContactId;
if (!isEmpty manager) {
  colleagues = find Contact by managerContactId == manager;
}

The above will check if the value for manager is empty. If that is not the case, then you start the rest of the logic. A better option is to actually make break clauses in your scripting, which stops the script if it is not necessary anymore. See belowDabei wird geprüft, ob der Wert für manager leer ist. Wenn das nicht der Fall ist, wird der Rest der Logik gestartet. Eine bessere Option ist es, Break-Klauseln in Ihre Skripte einzubauen, die das Skript anhalten, wenn es nicht mehr benötigt wird. Siehe unten.

Code Block
contact = this;
manager = contact.managerContactId;
if (isEmpty manager) {
  return;
}
colleagues = find Contact by managerContactId == manager;

This will make the script more readable and “safe”, as it terminates the logic once it should stop.

Find versus Get

In scripting, when using a “Find”, all items that match the parameters will be returned. When using a “Get”, only one item is returned. Even though only one item is returned, the “Get”-query is not quicker. Behind the screens, Workplace does a “Find” and just returns 1 item. So be aware that using this is not quicker.

Combine queries

In Workplace, it is possible to “link through” in queries. See the below scriptingDies macht das Skript lesbarer und "sicherer", da es die Logik beendet, sobald sie aufhören sollte.

Finden versus Erhalten

Bei der Skripterstellung werden bei einer "Suche" alle Elemente zurückgegeben, die mit den Parametern übereinstimmen. Bei der Verwendung von "Get" wird nur ein Element zurückgegeben. Auch wenn nur ein Element zurückgegeben wird, ist die "Get"-Abfrage nicht schneller. Hinter den Bildschirmen führt Workplace eine "Suche" durch und gibt nur 1 Element zurück. Seien Sie sich also bewusst, dass diese Methode nicht schneller ist.

Kombinieren Sie Abfragen

In Workplace ist es möglich, in Abfragen "durchzukoppeln". Siehe das folgende Skripting.

Code Block
contact = this;
manager = contact.managerContactId;
if (isEmpty manager) {
  return;
}
colleagues = find Contact by managerContactId == manager;
properties = [];
for each colleague in colleagues {
  properties = properties + find Property by ownerContactId == colleague;
}

Assuming the query on line 6 returns 10 colleagues, the “for each” will execute the properties query 10 times. A more optimal way is to combine the separate queriesAngenommen, die Abfrage in Zeile 6 liefert 10 Kollegen, dann wird die Abfrage "for each" die Eigenschaften 10 Mal ausführen. Optimaler ist es, die einzelnen Abfragen zu kombinieren.

Code Block
contact = this;
manager = contact.managerContactId;
if (isEmpty manager) {
  return;
}
properties = find Property by ownerContactId == NULL, Contact.managerContactId == manager;

What the scripting does here is to go from the object Property to the ownerContactId and then searches all the Contact who belong to a certain manager. This effectively lowers the total query amount from 11 to 1.

Queries with client specific fields/attributes

When performing a query using a client-specific field, this would potentially be quite small when using large numbers of objects (i.e. CodeTypes). In some cases, it might be quicker to collect all items and check on the specific value that you are interested in, instead of directly searching for the client-specific field value. This should be decided on a case-by-case basisDas Skript geht hier von der Objekteigenschaft zur ownerContactId und sucht dann alle Kontakte, die zu einem bestimmten Manager gehören. Dadurch wird die Gesamtzahl der Abfragen von 11 auf 1 gesenkt.

Abfragen mit kundenspezifischen Feldern/Attributen

Bei einer Abfrage über ein kundenspezifisches Feld wäre dies bei einer großen Anzahl von Objekten (z. B. CodeTypes) möglicherweise recht klein. In manchen Fällen kann es schneller sein, alle Elemente zu sammeln und den spezifischen Wert zu prüfen, an dem Sie interessiert sind, anstatt direkt nach dem Wert des kundenspezifischen Feldes zu suchen. Dies sollte von Fall zu Fall entschieden werden.

Code Block
reference = "REF-12345";
category = get Folder by reference == "CAT-12345";
var oneSpecificObject;

# Normally, you would do something like this:
if (!isEmpty reference) {
  oneSpecificObject = get CodeType by categoryFolderId == category, "acme-ExternalReference" == reference;
}

# But sometimes, this is quicker:
if (!isEmpty reference) {
  objects = find CodeType by categoryFolderId == category;
  for each object in objects {
    if (object."acme-ExternalReference" != reference) {
      continue;
    }
    oneSpecificObject = object;
    break;
  }
}

Echo’s in scripting

...

Echo's im Skripting

Es hat sich herausgestellt, dass Echos bei der Skripterstellung den belegten Heap-Speicherplatz auf dem Server erhöhen. Daher ist das Entfernen von Echos nach dem Debuggen eine gute Möglichkeit, Probleme auf dem Server zu vermeiden. Wenn Sie dies mit einem großen Knall in einer Client-Umgebung bereinigen wollen, können Sie das folgende Skript in dieser Umgebung ausführen:

Code Block
client = user.clientId;
scripts = find Script by clientId == client, scriptVersionId == NULL, ScriptVersion.scriptText contains "echo";
activeScriptVersions = [];
for each script in scripts {
    activeScriptVersions = activeScriptVersions + script.scriptVersionId;
}

for each scriptVersion in activeScriptVersions {
    scriptText = scriptVersion.scriptText;
    newScriptText = scriptText ~r/\s*echo.*//;
    newScriptVersion = copy scriptVersion;
    set newScriptVersion.scriptText = newScriptText;
    set newScriptVersion.description = "Automatic echo removal";
    set newScriptVersion.scriptStatusCode = Enums.ScriptStatus.active;
    script = newScriptVersion.scriptId;
    set script.scriptVersionId = newScriptVersion;
}

The above scripts does the following:

...

It gets all the scripts in which the latest script version creates the word “echo”

...

From that, it retrieves the active script versions

...

For each active version, it searches for all the echo’s in the script through a regular expression (line 10)

...

It then copies the existing version and replaces it with the echo-free text

...

Die obigen Skripte bewirken Folgendes:

  • Es werden alle Skripte ermittelt, in denen die neueste Skriptversion das Wort "echo" enthält.

  • Daraus werden die aktiven Skriptversionen abgerufen

  • Für jede aktive Version werden alle Echos im Skript mit Hilfe eines regulären Ausdrucks gesucht (Zeile 10)

  • Er kopiert dann die bestehende Version und ersetzt sie durch den echofreien Text

  • Es fügt eine Beschreibung zu dieser Version hinzu und aktiviert die neueste Version