Not a question, but something I thought might help others.
I have a custom table, and when creating a new record users need to have the ability to add a note and attachment(s). Once the record is submitted, it is read-only, so I have to gather everything prior to submitting the record. I am using the Dataverse Notes and Attachment tables.
I struggled with how to do it for a day or so, but here's how I did it:
- Enable Notes and Attachments on the custom table
- Create a text box for the note text
- Add an EditForm with only "Attachments" as described here.
- Change the "Item" property on the EditForm to the below. See here as to why.
If(IsBlank(lPatchRecord), Defaults(CustomTable), lPatchRecord)
- When submitting, use Patch as described in Step 3.
UpdateContext(
{
lPatchRecord: Patch(
CustomTable,
Defaults(CustomTable),
{
<fields here>
},
frmAttachments.Update
)
}
)
- Now that you have a record, Patch your Note. Optionally, add error trapping prior so you know if the record was created, notify the user, etc.
If(
!IsBlank(txtNoteText.Text),
Patch(
Notes,
Defaults(Notes),
{
Title: NoteTitle,
Regarding: lPatchRecord,
Description: txtNoteText.Text,
'Is Document': false
}
)
)
- Something I did not know until today, when you add a record to the Attachments table it also adds a record to the Notes table. So when I come back to the screen to view my Note, I thought the code would be First(lPatchRecord.Notes).Description. But no! Because I added the Attachment first, I had to use Last(lPatchRecord.Notes).Description.
Hope this helps someone down the road.

Report
All responses (
Answers (