0

Split Function Help

hi to all!

I have got this tables in Ninox:

TABLE: Genres

Field: Genre

TABLE: Masters

Field (in error): Genre

The field in TABLE Master can have 1 or more Genres, for example

(1 genre)

 (2 genres)

 

With the formula:

 

Here is the formula field:

let xGenre := "";
if Genres = null then xGenre := "" else xGenre := Genres end;

let g := first(select Genres where Genre = xGenre);
html(---

<span style="color: black">Genre: </span>
<span onclick="ui.openRecord('{ g }')"; style="color: #1E90FF; cursor: pointer; text-decoration: underline;">{ xGenre } <br></span>

---)

 

I am trying to have the possibility to link this field to the table called "Genres".

this correctly open the related record in the Table "Genres" only if the field in the table "Master" has one genre (first case), but do not work if genres are more than one.

I have tried to split the xGenres, but I have no chance.

 

Any help would be appreciated, as always

 

Thank you

37 replies

null
    • Fred
    • 1 yr ago
    • Reported - view
     said:
    Yes works, but how can I do for include more fields 

    Going off of my example this is how my code changes:

    let list := (
            let x := split(Text, ",");
            for item in x do
                let i := first(select Table1 where Country = item);
                "
        <span style=""color: black"">Country: </span>
        <span onclick=""ui.openRecord('" +
                raw(i) +
                "')""; style=""color: #1E90FF; cursor: pointer; text-decoration: underline;"">" +
                i.Country +
                "</span>
    <span style=""color: black"">Number: </span>
        <span onclick=""ui.openRecord('" +
                raw(i) +
                "')""; style=""color: #1E90FF; cursor: pointer; text-decoration: underline;"">" +
                i.Number +
                "</span>
                "
            end
        );
    html("" + list + "")
    

    As you can see I drop the use of the for loop variable: item and just use the variable: i to get my information. Also I had to move the static text out of the html() command and into the for loop so it get created for each instance. Then you just duplicate the same bit of code for the first link then change the static name and the field references.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

      let list := (
              let x := split(Name, ",");
              para el elemento en x,
                  let i := first(seleccione Álbumes donde Nombre = item);
                  "
          <aside class = 'double' style='text - align:center; font-family:Helvetica; font-size:14px; color:dimgray; background-color:#FFF;'> Información Artista/Álbum y Formato </aside> <span style=""color : negro
          " ">Nombre del artista: </span>
          <span onclick=""ui.openRecord('" +
                  raw(i) +
                  "')""; style=""color: #1E90FF; cursor: puntero; texto- decoración : subrayado;"">" +
                  i.Name +
                  "</span>
          <span style=""color: negro"">Título: </span>
          <span onclick=""ui.openRecord('" +
                  raw ( i) +
                  "')""; estilo=""color: #1E90FF; cursor: puntero; decoración de texto: subrayado;"">" +
                  i.Title +
                  "</span>
                  "
              end
          );
      html("" + lista + "")

      Gracias Fred, lo único que falta es el salto de línea. El <br> funciona pero no sé si es la mejor opción.

      • Fred
      • 1 yr ago
      • Reported - view

      <br> is fine.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

      Fred 

      Hi Fred have you tried this script ?, is tooo slow, does not go from  one record to another, other times yes, it is erratic. With two is the problem with one works perfect

      • Fred
      • 1 yr ago
      • Reported - view

      If you are talking about the one I post with two fields, then yes. it works for me. When I add <br> it works too.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

      Fred This one, but is very erratic, When go from one record to another no display the next record , other time yes.

      let list := (
              let x := split(Name, ",");
              for item in x do
                  let i := first(select Albums where Name = item);
                  "
          <span style=""color: black"">Artist Name: </span>
          <span onclick=""ui.openRecord('" +
                  raw(i) +
                  "')""; style=""color: #8140dd; "">" +
                  i.Name +
                  "</span><br>
          <span style=""color: black"">Title Name </span>
          <span onclick=""ui.openRecord('" +
                  raw(i) +
                  "')""; style=""color: #1E90FF; cursor: pointer; text-decoration: underline;"">" +
                  i.Title +
                  "</span>
                  "
              end
          );
      html("" + list + "")
      • Fred
      • 1 yr ago
      • Reported - view

      I don't think it is the code.

      I would check to make sure each data point has data and is in the correct format.

      What kind of field is Name? How does data get into the field? In the records that don't work, does the data in Name look different then the data in Name in records that work?

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

       Name is Formula is the Artist Name  from Albums.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

       Hi Fred sorry for the abuse, you can share this example. need to know what happend, everything's look fine

    • Fred
    • 1 yr ago
    • Reported - view
     said:
    you can share this example. need to know what happend, everything's look fine

     This is what I have:

    let list := (
            let x := split(Text, ",");
            for item in x do
                let i := first(select Table1 where Country = item);
                "
    <span style=""color: black"">Country: </span>
    <span onclick=""ui.openRecord('" +
                raw(i) +
                "')""; style=""color: #1E90FF; cursor: pointer; text-decoration: underline;"">" +
                i.Country +
                "</span>
    <span style=""color: black"">Number: </span>
    <span onclick=""ui.openRecord('" +
                raw(i) +
                "')""; style=""color: #1E90FF; cursor: pointer; text-decoration: underline;"">" +
                i.Number +
                "<br></span>
                "
            end
        );
    html("" + list + "")
    

    Try putting your <br> inside the <span></span>.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

       

      let x := split(Text, ",");
      
       Text ?
      
      • Fred
      • 1 yr ago
      • Reported - view

      Text is just a simple text field that has the list of country names, for me. It will vary in your DB. Can you post a sample of your DB?

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

      Fred, ok, entiéndelo ahora, gracias. 👍 the DB is to large Fred Have a lot of image's

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 37Replies
  • 412Views
  • 5 Following