0

Join without empty lines

Hi all,

I have a few fields (yes/no) to list all the papers that i might receive from people when they sign a contract. Let's say it's a list of ten different documents.

Some people deliver them all, others just a few of them.

I want to list those papers without having "empty lines" in the list. I used the join function in a formula field, but i get empty lines.

This is the formula i used:

let xDocId := if 'Doc_Identità' = 1 then
        "- Documento di riconoscimento (" + 'Tipo_Identità' + " n. " + 'NUMERO_Identità' + ") rilasciato da: " + 'RILASCIO_Identità' + " il giorno " + 'DATA_Identità' + " e valevole fino al giorno " + 'SCADENZA_Identità'
    else
        null
    end;
let xCodFisc := if Doc_CodiceFiscale = 1 then
        "- Copia del Codice Fiscale"
    else
        null
    end;
let xAutocer := if Doc_Autocertificazione = 1 then
        "- Dichiarazione sostitutiva di certificazione"
    else
        null
    end;
let xCasellario := if Doc_Casellario = 1 then
        "- Certificato penale del casellario giudiziale (art. 2 D.Lgs n. 39/2014)"
    else
        null
    end;
let xCarichi := if Doc_CarichiPendenti = 1 then
        "- Certificato dei carichi pendenti"
    else
        null
    end;
let xTitolo := if Doc_Titolo = 1 then
        "- Titolo di studio: " + Tipo_Titolo
    else
        null
    end;
let xSogg := if Doc_Soggiorno = 1 then
        "- Permesso di Soggiorno"
    else
        null
    end;
let xResidenza := if Doc_Residenza = 1 then
        "- Certificato di residenza"
    else
        null
    end;
let xFam := if Doc_Famiglia = 1 then
        "- Certificato di stato di famiglia"
    else
        null
    end;
let xNucleo := if Doc_Nucleo = 1 then
        "- Documentazione richiesta dalle leggi vigenti per assegni per nucleo famigliare"
    else
        null
    end;
join([xDocId, xCodFisc, xAutocer, xCasellario, xCarichi, xTitolo, xSogg, xResidenza, xFam, xNucleo], "
    ")

 and this is the result i get when i select just a few of them

Is there a way to achieve what i want?

10 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    No need of the else then null, also not using the join function is easier.

    Steven

    • Gianluca
    • 1 yr ago
    • Reported - view

    Thank you so much RoSoft_Steven

    seems like I’m good at making hard task out of easy things 😅

    • John_Halls
    • 1 yr ago
    • Reported - view

    Hi Gianluca

    A different take would be

    let a := ["One", "Two", "Three"];
    let b := ['Yes / No', 'Yes / No 2', 'Yes / No 3'];
    let c := ["x"];
    let i := 0;
    for d in b do
        if d then
            c := array(c, [item(a, i)])
        end;
        i := i + 1
    end;
    c := slice(c, 1, count(a) + 1);
    join(c, "
    ")
    

    Where a is an array of all your lines of text and b is an array of all your yes/no fields.

    Regards John

      • Gianluca
      • 1 yr ago
      • Reported - view

      John Halls great solution too. I need to learn better about the for function (and many others, actually), but my time for learning is less than I would love to have 😅

    • Créateur de bien-être
    • Sebastien_Guillet
    • 9 mths ago
    • Reported - view

    Hi,

    I find myself in a similar situation. When I want to display different texts in a formula while separating each type of text with a "-", I use the join() function

    The problem is that when I have empty fields, the join() function still adds the "-" which gives me several "-" in a row while I don't want to have any when an info is empty .

    Formula :

    let RappelImportant := if 'Rappel important' then 'Rappel important' end;
    let ActiviteAconfirmer := if 'Activités à confirmer' then
            "RDV à confirmer"
        end;
    let ContratAsigner := if 'Contrats à signer' then "Contrat à signer" end;
    let CarteCadeauAenvoyer := if 'Carte cadeau de fidélité à envoyer' = true then
            "Nouveau palier de fidélité"
        end;
    let CarteParrainAenvoyer := if 'Carte cadeau de parrainage à envoyer' = true then
            "Nouveau palier de parrainage"
        end;
    let PHV := if 'Envoyer plan d’hygiène vitale' = true then
            "Envoyer plan d'hygiène vitale"
        end;
    join([RappelImportant, ActiviteAconfirmer, ContratAsigner, CarteCadeauAenvoyer, CarteParrainAenvoyer, PHV], " - ")
    

    Result :

    Test - - - - Nouveau palier de parrainage - Envoyer plan d'hygiène vitale

    In this example, lines 2, 5 and 6 give no text to display. The "-" are still added which poses a problem for me to read the result.

    Is it possible to do something to avoid the extra "-"?

      • Créateur de bien-être
      • Sebastien_Guillet
      • 9 mths ago
      • Reported - view

      I forgot to specify that it is important for me that the result of the formula is empty if all the conditional values are empty

      • Alain_Fontaine
      • 9 mths ago
      • Reported - view

       Since the options are already in an array, just add the filter after the definition of the array:

      [!=""]

      • Créateur de bien-être
      • Sebastien_Guillet
      • 9 mths ago
      • Reported - view

       Thanks for your feedback. I have already tried adding !="" at several levels of my formula without it working. Would you have a working example to offer me based on my formula?

      • John_Halls
      • 9 mths ago
      • Reported - view

       Use this at the end of your code

      let a := [RappelImportant, ActiviteAconfirmer, ContratAsigner, CarteCadeauAenvoyer, CarteParrainAenvoyer, PHV];
      join(a[!=""],"-")
      

      The solution came from Alain in a previous post.

      Regards John

      • Créateur de bien-être
      • Sebastien_Guillet
      • 9 mths ago
      • Reported - view

       Your formula works perfectly. THANKS !

Content aside

  • 9 mths agoLast active
  • 10Replies
  • 146Views
  • 5 Following