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
-
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?
-
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 );
-
"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? -
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
- 2 days agoLast active
- 5Replies
- 52Views
-
2
Following