Applies the current address layout to all addresses of the same type
Takes the Address Layout of the current address and applies it to all addresses of the same type (company, person, contact, or couple).
This script should be used with caution and only in the Script Editor, as it really overwrites all layouts of the same address type. The operation cannot be undone.
| version | description | Scripting | 
|---|---|---|
| from version 5.8 | Python scripting | Addlayouttoalloftype.py | 
On the address containing the layout to be transferred.
#---Bezeichnung: Adresslayout einer Adresse auf andere übertragen
#   Klassen: Adresseintrag
#   ObjectScript: Yes
#   ContainerScript: No
#   EventType: Kein
#---Dieses Script nimmt das Adresslayout des aktuellen
#   Adresseintrags und überträgt es auf alle Adresseinträge, die
#   vom gleichen Typ (EinfacheAdresse, Firma, Person oder Kontakt) sind.
#---30.01.2004, Vertec AG: erstellt
#---07.05.2007, sr: Angepasst an argobject und vertec
#---04.03.2008, cp: Ergänzt um dynamische Anrede und Briefanrede
#---30.04.2009, bn: On Error eingefügt um Fehler abzufangen
#---25.10.2013, sr: msgox auf vertec.msgbox geändert
#---22.02.2019, sth: Script in Python umgeschrieben
def main():
    vtcapp.updatedatabase
    obj = argobject
    if obj.eval('oclisKindOf(Adresseintrag)'):
        layout = obj.defaultadresse
        lay = layout.adresslayout
        typ = obj.evalocl("oclType.asString")
        adrlist = vtcapp.evalocl(typ + ".allInstances")
        for adresse in adrlist: 
            try:
                adresse.anredetemplate = obj.anredetemplate
                adresse.briefanredetemplate = obj.briefanredetemplate
                layout = adresse.defaultadresse
                layout.adresslayout = lay
            except:
                if vtcapp.msgbox("Das Adresslayout konnte für folgende Adresse nicht gesetzt werden: %s. Wollen sie fortfahren?" % adresse.evalocl("self.asstring"),4) == 6:
                    continue
                else:
                    return
    else:
        vtcapp.msgbox("Dieses Skript muss auf einer einzelnen Adresse ausgeführt werden, von welcher das Layout auf alle Adressen dieses Typs übertragen wird.")
    vtcapp.updatedatabase
    
main()