0

Connect 2 entries

Hello.

I have this code in the table Solicituds in a button:

let dniActual := DNI;
let personaEncontrada := (select Personas where DNI = dniActual);
if count(personaEncontrada) > 0 then
    alert("El DNI ya existe.")
else
    alert("El DNI no existe.")
end

I want that, if count(personaEncontrada) > 0 the entries that exists in both are relationships with each other. Like As if I choose in the Relationship field the record to connect.

 

Thanks.

10 replies

null
    • Fred
    • 1 mth ago
    • Reported - view

    Can you post a sample DB?

    • FAIBDelegaciones
    • 1 mth ago
    • Reported - view

    Sorry I cant, I have Starter plan.

    The think is:

    Database Solicituds <-> Database Personas

    DNI field in Solicituds
    DNI field in Personas

    If DNI > 0 (find the same DNI field in Solicituds and Personas), then both entries with the coincident DNI in Solicitud and Personas needs to be linked.

    Thanks.

      • Fred
      • 1 mth ago
      • Reported - view

       Are you talking about separate databases or separate tables?

      • FAIBDelegaciones
      • 1 mth ago
      • Reported - view

      Separated tables in the same Database

    • Fred
    • 1 mth ago
    • Reported - view
     said:
    Database Solicituds <-> Database Personas
    DNI field in Solicituds DNI field in Personas
    If DNI > 0 (find the same DNI field in Solicituds and Personas), then both entries with the coincident DNI in Solicitud and Personas needs to be linked.

    Thankfully, you only need to link on one end. Is there a 1 to many link between Solicituds and Personas? or will there only ever be a 1:1 relationship?

    If there will be a 1 to many, which end is the many side? If you edit the reference field you will see something like:

    This means that there is 1 Invoice to many Data Entry.

    Another way to tell which side the table is on is if you see if the relationship fields shows up as a single field or a table. The single field means it is the many side (it can link to only 1 record). If you see a table then that means the table is the 1 side, the table shows the many records that are linked to it.

    So on 1 side table you can create a button with:

    let t := this;
    let otherTableRecs := (select otherTableName where DNI = t.DNI);
    for loop1 in otherTableRecs do
        loop1.(referenceFieldName := t)
    end
    
      • FAIBDelegaciones
      • 1 mth ago
      • Reported - view

      Detailed:

      1. Solicitudes table, field DNI (text field)

      2. Link to Personas table inside Solicitudes table

      If in Personas-DNI field (text) is the same DNI as in Solicitudes-DNI field, then I want to link the Solicitudes entry with the Personas entry. In Personas will be only 1 entry with the same DNI.

       

      Thanks.

      • Fred
      • 1 mth ago
      • Reported - view

      You can try:

      In Personas table create a button with:

      let t := this;
      let solicitudesRecs := (select Solicitudes where DNI = t.DNI);
      for loop1 in solicitudesRecs do
          loop1.(Personas := t)
      end
      
      • FAIBDelegaciones
      • 1 mth ago
      • Reported - view

      I need the button in Solicituds table. It's possible?

      • Fred
      • 1 mth ago
      • Reported - view

      of course:

      let t := this;
      let personasRec := first(select Personas where DNI = t.DNI);
      Personas := personasRec

      Line 2 is assuming that there will only ever be one Personas record with a matching DNI. If there will be multiple then you need to figure out how you want to differentiate between them.

      • FAIBDelegaciones
      • 1 mth ago
      • Reported - view

      GENIUS!!! thanks!

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 10Replies
  • 50Views
  • 2 Following