0

Register data in a underlaying child-table

I am trying to register the email in a separate underlying table; what am I doing wrong?
The table is called 'E-post.

sendEmail({
    from: userEmail(user()),
    to: 'E-postadresse',
    cc: CC.'E-postadresse',
    bcc: BCC.'E-postadresse',
    subject: Emne,
    text: Melding,
    html: Melding,
    attachments: files(this)
});
select 'E-post'; (Table)
let a := Id;
let d := Tidspunkt;
let t := 'E-postadresse';
let c := CC;
let b := BCC;
let s := Emne;
let e := Melding;
let h := Melding;
let ep := (create 'E-post').Id;
ep.(Tidspunkt := d);
ep.'E-postadresse'.('E-postadresse' := t);
ep.CC.('E-postadresse' := c);
ep.BCC.('E-postadresse' := b);
ep.(Emne := s);
ep.(Melding := e);
ep.(Melding := h)

5 replies

null
    • Fred
    • 1 mth ago
    • Reported - view

    What is the table name this script is running in? Is it in a trigger or button?

    What is the relationship between the table that the script is in and E-post? If there is a relationship what are the names of the relationship fields in each table?

      • Standpunktet
      • Jan_Inge_Iversen.1
      • 1 mth ago
      • Reported - view

       
      Its in a button and the relationship is between the tables "E-mail addresse" and "E-mail".
      In Norwegian it is "E-postadresse" and "E-post".

    • Fred
    • 1 mth ago
    • Reported - view

    Are E-postadresse, CC, and BCC reference fields? I can guess where E-postadresse is linked to but where is CC and BCC linked to?

    You have variable e & h linked to the same field, Melding then they point to the same field names later on. Is there a reason why you set the Melding field twice?

    If the button is in the E-post table then something like this should work:

    let t := this;
    let ep := (create 'E-post');
    ep.(
        Tidspunkt := t.Tidspunkt;
        'E-postadresse' := t;
        Emne := t.Emne;
        Melding := t.Melding
    );
    
    
    • Standpunktet
    • Jan_Inge_Iversen.1
    • 1 mth ago
    • Reported - view

    "Are E-postadresse, CC, and BCC reference fields?" Yes, all of them.

    "You have variable e & h linked to the same field, Melding then they point to the same field names later on. Is there a reason why you set the Melding field twice?"
    I haven´t seen it before now actually, so I dont know why. But I guess thats not important for the results?

    • Fred
    • 1 mth ago
    • Reported - view

    Are the CC and BCC tables built as a many to many (N:N) between E-post and E-postadresse?

    Also the CC and BCC tables are the many side (N:1) to E-post and E-postadresse, correct?

    That means you need to create a new record in CC and BCC before you can link them to the new E-post.

    let t := this;
    let ep := (create 'E-post');
    ep.(
        Tidspunkt := t.Tidspunkt;
        'E-postadresse' := t.'E-postadresse';
        Emne := t.Emne;
        Melding := t.Melding
    );
    let newCC := (create CC);
    newCC.(
        'E-post' := ep;
    );
    
    

    I'm not sure why you would connect the same E-postadresse record to E-postadresse and CC and BCC.

Content aside

  • 1 mth agoLast active
  • 5Replies
  • 59Views
  • 2 Following