Recursive display name formula

Cardbook for Thunderbird Forums Main Forum Recursive display name formula

Viewing 4 reply threads
  • Author
    • #3084


      Is the display name formula recursive ?

      I mean: can a block contain another block ?

      I would like to have:

      • GivenName FamilyName

      without organization even if present. Or

      • Organization

      Basically, use organization only if no name is available.

      This is similar to this question

      Displayed name question

      but the answer does not work when only the given name and organization is filled. The result would be

      • GivenName Organization

      I tried different formulas, but could not achieve the result I want.

      Thank you

    • #3085

      formula are not recursive, but this should do the trick :

      ({{1}}{{2}}{{3}}{{4}}{{5}}{{6}}||{{7}}|{{2}} {{4}})

      means if “{{1}}{{2}}{{3}}{{4}}{{5}}{{6}}” is null then {{7}} else “{{2}} {{4}}”

    • #3086

      Thank You CardBook 🙂

      I simplified it a bit and came up to:

      ({{2}}{{4}}||{{7}}|{{2}} {{4}})

      The organization only appears only when there is no given or family name.

      I guess the same would better answer the mentioned question. Even if rather old, it is still findable by the search engine.


      • #3225

        Even simpler, tested with 55.5

        ({{2}} {{4}} | {{7}})

    • #3220

      The formulas above work, but they have a slight problem: if only one of GivenName or FamilyName is empty, there will be a leading or trailing space besides the other (non-empty) name in the generated display name.

      This one fixes that issue:

      <span style=”font-size: 12px;”>({{2}})(?[{{2}}]??[{{4}}]?|*|?[]?|| )({{4}})({{2}}{{4}}||{{7}}|)</span>

      The key is the (?[{{2}}]??[{{4}}]?|*|?[]?|| ) part, which doesn’t add a space between the two names if the string formed by nesting each of them between ?[ and ]? and concatenating them contains ?[]?, indicating at least one of them is empty.

      This of course assumes that the sequence ?[]? doesn’t appear in the names themselves. If someone’s into ASCII art 🙂 you’ll have to choose a more complicated unique pattern.

      • #3224

        Your are right when testing in the Preview zone (in address book properties), there is a leading or trailing space.

        But if you save it with my formula and edit a card, there seem to be a trim on the final value and there is no extra space.

        So my formula still does the job and stays much more simple 🙂

        Maybe a issue to fix is to also apply the final trim in the preview.
        <div id=”simple-translate”>
        <div class=”simple-translate-button isShow” style=”background-image: url(‘moz-extension://c9b41712-0f51-4fb1-88aa-0cda8194749b/icons/512.png’); height: 22px; width: 22px; top: 161px; left: 189px;”></div>
        <div class=”simple-translate-panel ” style=”width: 300px; height: 200px; top: 0px; left: 0px; font-size: 13px; background-color: #ffffff;”>
        <div class=”simple-translate-result-wrapper” style=”overflow: hidden;”>
        <div class=”simple-translate-move” draggable=”true”></div>
        <div class=”simple-translate-result-contents”>
        <p class=”simple-translate-result” style=”color: #000000;”></p>
        <p class=”simple-translate-candidate” style=”color: #737373;”></p>


    • #3223

      I’ve added the recursion for formulas, if you want to test :

Viewing 4 reply threads
  • You must be logged in to reply to this topic.